I am trying to create a virtualenv inside jenkins job and then install requirements.txt. But I am unable to create virtualenv. This is what my Jenkins file look like.
sh 'sudo easy_install pip; pip install virtualenv'
But I am getting
+ sudo easy_install pip
Searching for pip
Best match: pip 9.0.1
Processing pip-9.0.1-py2.7.egg
pip 9.0.1 is already the active version in easy-install.pth
Installing pip script to /usr/local/bin
Installing pip2.7 script to /usr/local/bin
Installing pip2 script to /usr/local/bin
Using /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg
Processing dependencies for pip
Finished processing dependencies for pip
+ pip install virtualenv
/Users/Shared/Jenkins/Home/workspace/test-jenkinsfile#tmp/durable-e0a93859/script.sh: line 3: pip: command not found
The pip command cannot be found within the user's path. the solution is either call it directly from /usr/local/bin/pip or add /usr/local/bin to the user's path
for bash: PATH=${PATH}:/usr/local/bin
for (t)csh: setenv PATH "${PATH}:/usr/local/bin"
Related
I installed pip through brew, and I can't get it to use python 3 instead of 2.7. Here's the information I think might be relevant to demonstrate what's happening.
$ pip -V
pip 9.0.1 from /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7)
$ pip2 -V
pip 9.0.1 from /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7)
$ pip3 -V
-bash: pip3: command not found
$ which pip
/usr/local/bin/pip
$ sudo python3 get-pip.py
The directory '/Users/tj/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/tj/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already up-to-date: pip in /usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
$ sudo easy_install3 pip
sudo: easy_install3: command not found
$ sudo easy_install-3.6 pip
sudo: easy_install-3.6: command not found
$ sudo easy_install pip
Searching for pip
Best match: pip 9.0.1
Processing pip-9.0.1-py2.7.egg
pip 9.0.1 is already the active version in easy-install.pth
Installing pip script to /usr/local/bin
Installing pip2.7 script to /usr/local/bin
Installing pip2 script to /usr/local/bin
Using /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg
Processing dependencies for pip
Finished processing dependencies for pip
I tried everything I could find online with no luck. The main symptom of this problem is when I use pip to install a package, it always goes into 2.7 (or fails to install because numpy is deprecated or something like that).
On OSX, brew (or other) python 2.7/3 is installed separately to the older version of 2.7 that comes with OSX. Trust me when I say you DO NOT WANT TO MESS WITH IT.
Try typing pip3
$ pip3 --version
$ pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)
Whereas pip (for 2.7) is not even installed.,
$ pip --version
$ zsh: command not found: pip
Even if you try:
$ brew install pip
Leads to
If you meant "pip" specifically:
Homebrew provides pip via: `brew install python`. However you will then
have two Pythons installed on your Mac, so alternatively you can install
pip via the instructions at:
https://pip.readthedocs.io/en/stable/installing/
AS A LAST RESORT:
python3 -m ensurepip
will ensure/fix a system has it.
pip3 should be located at /usr/local/bin/pip3
Contents are:
#!/usr/local/opt/python3/bin/python3.6
# EASY-INSTALL-ENTRY-SCRIPT: 'pip==9.0.1','console_scripts','pip3'
__requires__ = 'pip==9.0.1'
import re
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(
load_entry_point('pip==9.0.1', 'console_scripts', 'pip3')()
)
Could you tell me how to install packages using pip on Go daddy Linux hosted server. It doesn't provide root access.
When I try to install some python package
pip install numpy
it shows:
-bash: pip: command not found
It is giving my Python 2.6.6 and the location is:
/usr/bin/python
Is there any hack for it?
You don't have pip installed. To install pip run this
easy_install --user pip
This will install pip for only you, without root access. If you don't have 'easy_installed' installed, you can run this to install pip without it
wget https://bootstrap.pypa.io/get-pip.py && python get-pip.py --user
pip will be installed in .local/bin, to access it just use
.local/bin/pip install numpy
To add pip to your PATH, so that you could access it like pip install numpy
execute this command:
echo "PATH=\$PATH:~/.local/bin" >> ~/.bashrc
and then this:
source ~/.bashrc
On my Ubuntu 16.04 Desktop I have python2.7.12 and python3.6.1 installed.
seept#seept:~$ python --version
Python 2.7.12
seept#seept:~$ python3 --version
Python 3.6.1
And I also installed pip and pip3. Is it true that pip is for python2 and pip3 is for python3?
So why the hell both versions of pip shows me this:
seept#seept:~$ pip --version
pip 9.0.1 from /home/seept/.local/lib/python3.5/site-packages (python 3.5)
seept#seept:~$ pip3 --version
pip 9.0.1 from /home/seept/.local/lib/python3.5/site-packages (python 3.5)
Why Python 3.5?
seept#seept:~$ which python
/usr/bin/python
seept#seept:~$ which python3
/usr/local/bin/python3
seept#seept:~$ which pip
/home/seept/.local/bin/pip
seept#seept:~$ which pip3
/home/seept/.local/bin/pip3
So my real problem is that I need the module 'requests' for a python3 project.
When I run:
seept#seept:~$ sudo pip3 install requests
This is the output:
The directory '/home/seept/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/seept/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
**Requirement already satisfied: requests in ./.local/lib/python3.5/site-packages**
By the way I always get this message:
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
So this output says I am using pip verison 8.1.1 but when I run pip --version it says me I am running version 9.0.1.
For me it looks like I already messed it up and should reinstall all?
You should run your project with virtualenv. It keeps safe your project directory and avoids conflict with other versions well.
Go to your project directory and just install first virtualenv using:
pip install virtualenv
Before installing your packages run this to activate virtualenv:
source venv/bin/activate
Now your directory is safe and you can install your package here to remain safe and unique from another directory.
Hope you understand my concept.
Thanks.
I upgraded to the new version of Pycharm. In the terminal, it says bash-3.2$ instead of my username. When I tried to install a library, it said that pip command is not found:
bash: pip: command not found
So I installed pip:
bash-3.2$ sudo easy_install pip
Searching for pip
Best match: pip 8.1.2
pip 8.1.2 is already the active version in easy-install.pth
Installing pip script to /usr/local/bin
Installing pip3.5 script to /usr/local/bin
Installing pip3 script to /usr/local/bin
Using /Library/Python/2.7/site-packages
Processing dependencies for pip
Finished processing dependencies for pip</i>
Okay, now all I have to do is use pip to install a library, right?
But then, this happens:
bash-3.2$ pip install pandas
bash: pip: command not found
I don't understand what I have to do to actually install pip. Or should I use sudo easy_install [library]?
I know that this is not precisely what you're asking, but PyCharm has its own built-in package manager. You should not have to use pip manually.
File->Settings->Project Interpreter
https://www.jetbrains.com/help/pycharm/2016.3/installing-uninstalling-and-upgrading-packages.html
there you can manage the installed packages for the selected Python interpreter or virtualenv.
Run this command on your terminal. pip will be installed without any issue.
sudo [your package manager] install python-pip python-dev build-essential
If it is not solved. The problem might be PATH problem.
Type echo $PATH on terminal. There should be /usr/local/bin in the output. If it is not type PATH=$PATH:/usr/local/bin to add /usr/local/bin to PATH
I am trying to install twisted on python 2.6 and it seems that the Zop interface is missing.
Also it seems that it is a .egg file. I downloaded this .egg file, now how can I install it?
Install virtualenv, which includes pip. Then you can simply run:
pip install twisted
pip will handle installing the zope.interface.
Instructions for installing virtualenv and pip on OS X
This is how I installed virtualenv and pip on OS X:
curl -O http://peak.telecommunity.com/dist/ez_setup.py
sudo python ez_setup.py
sudo easy_install pip
sudo pip install virtualenv
I also like to use virtualenvwrapper with virtualenv, so I installed it using:
sudo pip install virtualenvwrapper
Instructions for installing Twisted in a virtualenv
Now to create a new virtual environment and install Twisted, I simply issue:
mkvirtualenv twisted-env
pip install twisted