I have been following the instructions on http://docs.python-guide.org/en/latest/starting/install/osx/ but for some reason this is not going as I believe it would be expected.
I have python 2.7 running by default but had to get easy_install up-to-date by following the instructions on: https://superuser.com/questions/256717/easy-install-the-wrong-version-of-python-modules-mac-os and link it from /usr/local/bin/share to /usr/local/bin. It seems to be working fine.
The problem is that now when I install pip it seems to install to 2.6 and not 2.7.
darky:~ user$ easy_install --upgrade pip
Searching for pip
Reading http://pypi.python.org/simple/pip/
Reading http://pip.openplans.org
Reading http://www.pip-installer.org
Best match: pip 1.1
Processing pip-1.1-py2.6.egg
pip 1.1 is already the active version in easy-install.pth
Installing pip script to /usr/local/bin
Installing pip-2.6 script to /usr/local/bin
Using /Library/Python/2.6/site-packages/pip-1.1-py2.6.egg
Processing dependencies for pip
Finished processing dependencies for pip
After the comments from MartijnPieters this problem NO LONGER persists
darky:~ user$ /usr/local/share/python/easy_install-2.7 pip
Searching for pip
Best match: pip 1.1
Processing pip-1.1-py2.7.egg
pip 1.1 is already the active version in easy-install.pth
Installing pip script to /usr/local/share/python
Installing pip-2.7 script to /usr/local/share/python
Using /usr/local/lib/python2.7/site-packages/pip-1.1-py2.7.egg
Processing dependencies for pip
Finished processing dependencies for pip
darky:~ user$ pip install virtualenv --upgrade
Requirement already up-to-date: virtualenv in /Library/Python/2.6/site-packages
Cleaning up...
But pip still creates environments with python-2.6. So I have to point it to the proper pyhton interpreter.
darky:pytravisci pedrorodrigues$ virtualenv --python=/usr/local/bin/python2.7 ENV
Running virtualenv with interpreter /usr/local/bin/python2.7
New python executable in ENV/bin/python
Installing setuptools............................done.
Installing pip...............done.
You can use
easy_install-2.7
or if you don't have that alias:
python2.7 -m easy_install <stuff>
For pip:
pip2.7
Related
I already had python3.8 installed and I installed python3.4 from its source code.
I wanted pip==19.1.1 as it is supported in python3.4. After installing pip when I tried changing its version but it was showing different version as you can see in the attached image.
Is there a way to use pip with version 19.1.1?
Thank you in advance.
remus#remus-VirtualBox:~$ python3.4 --version
Python 3.4.0
remus#remus-VirtualBox:~$ sudo apt install python3-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-pip is already the newest version (20.0.2-5ubuntu1.6).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
remus#remus-VirtualBox:~$ pip install pip==19.1.1
Collecting pip==19.1.1
Using cached pip-19.1.1-py2.py3-none-any.whl (1.4 MB)
Installing collected packages: pip
WARNING: The scripts pip, pip3 and pip3.8 are installed in '/home/remus/.local/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-19.1.1
remus#remus-VirtualBox:~$ pip -V
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)
Terminal Image showing error
OS: UBUNTU 20.04.4(Focal)
I strongly recommend to use something like venv or conda to create your environments. That would allow you the hassle of having to distinguish multiple python binaries on your machine.
That said, I think your issue can be resolved by explicitly using the right python version by launching pip like this:
python3.4 -m pip --version
For example, I have two different python versions installed (shame on me!) and this is the output I get:
generic#motorbrot:~$ python --version
Python 2.7.17
generic#motorbrot:~$ python -m pip --version
pip 9.0.1 from /usr/lib/python2.7/dist-packages (python 2.7)
generic#motorbrot:~$ python3 --version
Python 3.6.9
generic#motorbrot:~$ python3 -m pip --version
pip 21.1.2 from /home/generic/.local/lib/python3.6/site-packages/pip (python 3.6)
I was tired of seeing the warning so figured I'd update pip from 21.0.1 to 21.1.2, however, when using the command D:\Python38\python.exe -m pip install --upgrade pip, or python -m pip install --upgrade pip, the version never changes to 21.1.2. I have restarted my terminal, I have checked my path, the only thing I can think is that I changed the global.cache dir to my D: drive to conserve space on my windows hog of a machine. Here is a snippet from my terminal of what I have going on.
D:\>python -V
Python 3.8.8
D:\>pip -V
pip 21.0.1 from d:\python38\lib\site-packages\pip (python 3.8)
D:\>python -m pip install --upgrade pip
Collecting pip
Using cached pip-21.1.2-py3-none-any.whl (1.5 MB)
Installing collected packages: pip
Successfully installed pip-21.1.2
WARNING: You are using pip version 21.0.1; however, version 21.1.2 is available.
You should consider upgrading via the 'D:\Python38\python.exe -m pip install --upgrade pip' command.
D:\>pip -V
pip 21.0.1 from d:\python38\lib\site-packages\pip (python 3.8)
D:\>python -m pip install --upgrade --no-cache pip
Collecting pip
Downloading pip-21.1.2-py3-none-any.whl (1.5 MB)
|████████████████████████████████| 1.5 MB 939 kB/s
Installing collected packages: pip
Successfully installed pip-21.1.2
WARNING: You are using pip version 21.0.1; however, version 21.1.2 is available.
You should consider upgrading via the 'D:\Python38\python.exe -m pip install --upgrade pip' command.
D:\>pip -V
pip 21.0.1 from d:\python38\lib\site-packages\pip (python 3.8)
my pip config debug info:
D:\>pip config debug
env_var:
env:
global:
C:\ProgramData\pip\pip.ini, exists: False
site:
d:\python38\pip.ini, exists: False
user:
C:\Users\logan\pip\pip.ini, exists: False
C:\Users\logan\AppData\Roaming\pip\pip.ini, exists: True
global.target: D:\Git\pip\site-packages
global.cache: D:\Git\pip\cache
global.pip-cache-dir: D:\Git\pip\cache
I have scoured the internet for an inkling into why this is happening but I can't seem to find an answer. Thing is, this isn't something that I have to have done, it's just nagging at me that I cant figure it out at this point.
I have read through the pip documentation config file and user guide and of course I have looked for my answer here before asking my question, I hope someone out there can give me some insight and thank you for your time.
So I've installed python via homebrow. When I do brew info python I get this:
python: stable 3.6.5 (bottled), devel 3.7.0rc1, HEAD
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/usr/local/Cellar/python/3.6.5_1 (5,107 files, 103.0MB) *
Poured from bottle on 2018-06-18 at 10:15:49
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/python.rb
==> Dependencies
Build: pkg-config ✔, sphinx-doc ✘
Required: gdbm ✔, openssl ✔, readline ✔, sqlite ✔, xz ✔
Optional: tcl-tk ✘
==> Options
--with-tcl-tk
Use Homebrew's Tk instead of macOS Tk (has optional Cocoa and threads support)
--devel
Install development version 3.7.0rc1
--HEAD
Install HEAD version
==> Caveats
Python has been installed as
/usr/local/bin/python3
Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
/usr/local/opt/python/libexec/bin
If you need Homebrew's Python 2.7 run
brew install python#2
Pip, setuptools, and wheel have been installed. To update them run
pip3 install --upgrade pip setuptools wheel
You can install Python packages with
pip3 install <package>
They will install into the site-package directory
/usr/local/lib/python3.6/site-packages
See: https://docs.brew.sh/Homebrew-and-Python
I'm ultimately trying to do pip3 install numpy but when I do that, I get this message:
-bash: pip3: command not found
pip install numpy seems to point to the Apple default 2.7 python version:
Requirement already satisfied: numpy in /Library/Python/2.7/site-packages (1.14.5)
So the problem seems to be in my .bash_profile as which python gives /usr/bin/python.
Here's what that looks like:
export PATH=/usr/local/bin:$PATH
export PATH=/usr/local/Cellar/python/3.6.5_1/bin:$PATH
[[ -s "$HOME/.profile" ]] && source "$HOME/.profile" # Load the default .profile
export PATH=$PATH:/Users/thammond/Library/Android/sdk/platform-tools
###########
export PATH=/usr/local/Cellar/postgresql\#9.6/9.6.6/bin:$PATH
###########
export ANDROID_HOME=$HOME/Library/Android/sdk
export PATH=$PATH:$ANDROID_HOME/tools
export PATH=$PATH:$ANDROID_HOME/platform-tools
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
I confirmed that /usr/local/ was listed at the top and also tried adding in export PATH=/usr/local/Cellar/python/3.6.5_1/bin:$PATH
But it's still finding the wrong python. Any ideas where I'm going wrong?
EDIT:
When I run python3 -m ensurepip --upgrade I see this:
Requirement already up-to-date: setuptools in ./Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
Requirement already up-to-date: pip in ./Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
When I run python3 -m ensurepip -vvv -U I get this:
Ignoring indexes: https://pypi.python.org/simple
0 location(s) to search for versions of setuptools:
Skipping link /var/folders/7d/xvqc5yxs10n6206lytrbs9wm0000gn/T/tmpk6_9t6c2 (from -f); not a file
Skipping link file:///private/var/folders/7d/xvqc5yxs10n6206lytrbs9wm0000gn/T/tmpk6_9t6c2/pip-9.0.3-py2.py3-none-any.whl; wrong project name (not setuptools)
Found link file:///private/var/folders/7d/xvqc5yxs10n6206lytrbs9wm0000gn/T/tmpk6_9t6c2/setuptools-39.0.1-py2.py3-none-any.whl, version: 39.0.1
Local files found: /private/var/folders/7d/xvqc5yxs10n6206lytrbs9wm0000gn/T/tmpk6_9t6c2/setuptools-39.0.1-py2.py3-none-any.whl
Installed version (39.2.0) is most up-to-date (past versions: 39.0.1)
Requirement already up-to-date: setuptools in ./Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
0 location(s) to search for versions of pip:
Found link file:///private/var/folders/7d/xvqc5yxs10n6206lytrbs9wm0000gn/T/tmpk6_9t6c2/pip-9.0.3-py2.py3-none-any.whl, version: 9.0.3
Skipping link file:///private/var/folders/7d/xvqc5yxs10n6206lytrbs9wm0000gn/T/tmpk6_9t6c2/setuptools-39.0.1-py2.py3-none-any.whl; wrong project name (not pip)
Local files found: /private/var/folders/7d/xvqc5yxs10n6206lytrbs9wm0000gn/T/tmpk6_9t6c2/pip-9.0.3-py2.py3-none-any.whl
Installed version (10.0.1) is most up-to-date (past versions: 9.0.3)
Requirement already up-to-date: pip in ./Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
Cleaning up...
When I look in /usr/local/Cellar/python/3.6.5_1/bin/ with finder I don't see a pip/pip3 file.
Did you try to invoke /usr/local/Cellar/python3/3.6.5_1/bin/pip3 ? If it works, it means pip installation has been successfuly completed and your bashfile will be wrong. However, the bashfile looks normal for me.
Did you confirm that there is pip3 in /usr/local/Cellar/python3/3.6.5_1/bin/?
If it does not exist, pip is not installed in the first place.
It seems to have the same problem with this page ("pip3 not installed with python 3.4.2 #33897").
The questioner of "pip3 not installed with python 3.4.2 #33897" have finaly solved it by removing /private/var/folders/hy/l_6wd1ps0nz835v4g41zhhtr0000gn/T/pip_build.
It may be because of Brew had failed to complete pip installation.
First, to bootstrap the pip installer, hit python3 -m ensurepip --upgrade and python -m ensurepip.
If it won't work, try to hit python3 -m ensurepip -vvv -U and tell what do it say.
I'm not really sure why it worked this time but just for kicks I decided to uninstall and reinstall python from homebrew again but this time it worked and pip3 installed correctly and works.
brew uninstall python3
brew install python3
now I can run pip3 install numpy --user
I've got a brand new kubuntu 14.04.01 LTS. It has only python 2.7 supported. I need 2.6 for my work. I've found the deadsnakes repositories and I've been able to install python2.6. But now I can't find a way to install pip for python 2.6 - how can I do that?
Following #AvishBabu's answer, I downloaded the easy setuptools 2.6 egg, so I have easy_install-2.6, but it's installed inside my /usr/local/lib/python2.7/dist-packages... When I try to install pip for 2.6, I get:
$ sudo easy_install-2.6 pip
Searching for pip
Best match: pip 1.5.4
Adding pip 1.5.4 to easy-install.pth file
Installing pip script to /usr/local/bin
Installing pip2.7 script to /usr/local/bin
Installing pip2 script to /usr/local/bin
Using /usr/lib/python2.7/dist-packages
Processing dependencies for pip
Finished processing dependencies for pip
which means, that only pip2.7 is taken into account.
You have to install setuptools for Python 2.6 (example :
setuptools-0.6c11-py2.6.egg). Then, you have easy_install-2.6.
You can do:
Use the command
easy_install-2.6 pip
For installing the mysql-python, use like pip-2.6 install mysql-python.
See reference.
On a windows 7 machine I have pip version 1.5.6 installed:
pip 1.5.6 from C:\Users\dietz\PNC\tas\ENV\lib\site-packages (python 2.7)
In order to find the reason for an error I want to install a different version of pip, which worked fine for me. So how can I uninstall pip and install version 1.2.1 instead?
pip itself is just a normal python package. Thus you can install pip with pip.
Of cource, you don't want to affect the system's pip, install it inside a virtualenv.
pip install pip==1.2.1
If downgrading from pip version 10 because of PyCharm manage.py or other python errors:
python -m pip install pip==9.0.1
If you want to upgrade or downgrade to different version of pip, better use --upgrade option at one go instead doing it in two steps. i.e. first uninstalling the existing and then re-installing to new version, below does both in one go as shown below.
USE: Executed on WIN10 with Bash
python -m pip install --upgrade pip==19.2.3
$ python -m pip install --upgrade pip==19.2.3
Collecting pip==19.2.3
Using cached pip-19.2.3-py2.py3-none-any.whl (1.4 MB)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 21.3.1
Uninstalling pip-21.3.1:
Successfully uninstalled pip-21.3.1
Successfully installed pip-19.2.3
well the only thing that will work is
python -m pip install pip==
you can and should run it under IDE terminal (mine was pycharm)
If you have to downgrade pip version do following steps:
step1. pip uninstall pip
step2. pip install pip==version number you want to install or downgrade
step3. check version of pip using pip --version
This process also works when any other package giving error exit code(2) you can follow these steps and install your package.