Unable to upgrade to pip 1.4.1 for Python2.7 - python

I installed pip via easy_install but on checking pip version it still shows:
pip 1.0.1 from /Library/Python/2.6/site-packages/pip-1.0.1-py2.6.egg (python 2.6)
This is how PIP installation took place:
Searching for pip
Best match: pip 1.4.1
Processing pip-1.4.1-py2.7.egg
pip 1.4.1 is already the active version in easy-install.pth
Installing pip script to /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin
Installing pip-2.7 script to /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin
Using /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-1.4.1-py2.7.egg
Processing dependencies for pip

You have a Python version collision, between the system Python on OSX and the one you installed. This can be resolved in several ways, but I highly recommend you reinstall Python via Homebrew. When installing Python with Homebrew, pip and setup_tools will also be installed as well and everything will be taken care of (you will not need to use sudo to install Python modules).
See: https://github.com/Homebrew/homebrew/wiki/Homebrew-and-Python
You will save yourself many headaches using Homebrew to manage your Python distribution.

Related

Is there a Pip command to check which python version a package needs?

I need to compile a list of packages I've installed that will no longer work with the upgrade from python 3.9 to 3.10. I'm guessing I'll need a pip command to check which python version the package requires. I know you can do this manually but I am looking for a pip command.
If there isn't one, is there some sort of standard way to check which packages will not work when you upgrade your python version without just cold upgrading and seeing what breaks?
To see the list of installed packages:
pip3 list
To see outdated packages:
pip3 list -o or --outdated
To upgrade a package:
pip3 install --upgrade <package_name>

Upgrading packages with pip is not working properly

I am using pip in Ubuntu 20.04 with Python 3.8. I am trying to upgrade some packages and it seems to work since it does not give any error message. However, if I do pip show for the desired package, the version remains unchanged.
For instance, in the case of pip itself I am doing the following:
python -m pip install --upgrade pip
And I am obtaining:
Collecting pip
Using cached pip-20.3.3-py2.py3-none-any.whl (1.5 MB)
Installing collected packages: pip
Successfully installed pip-20.3.3
Then, when I try to check the installed version with pip show pip, I get the following:
Name: pip
Version: 20.0.2
Summary: The PyPA recommended tool for installing Python packages.
Home-page: https://pip.pypa.io/
Author: The pip developers
Author-email: pypa-dev#groups.google.com
License: MIT
Location: /usr/lib/python3/dist-packages
Requires:
Required-by: pip-upgrade
I have observed this problem also for scipy. However, I have been able to upgrade virtualenv and seaborn following the same procedure described above.
On the other hand, if I do the same upgrade process using sudo it does work. However, I would like to have the new versions installed not only for superuser.
Thanks in advance.
You may have multiple installations of Python on your system.
First provide the full name for Python 3.8 when installing pip to make sure it is installing pip for 3.8.
python3.8 -m pip install --upgrade pip
You could also try to use the pip specifically for Python 3.8. It is usually called pip3.8.
It could also be the environment you are installing it in. It's better to use pip --version so that you know where it is pulling pip from, as well the version of Python being used.
pip3.8 --version
pip 20.3.3 from /home/eandersson/.local/lib/python3.8/site-packages/pip (python 3.8)
As you can see here depending on the user and env variables set it may be installed in a different location.
sudo pip3.8 --version
pip 20.2.3 from /usr/local/lib/python3.8/dist-packages/pip (python 3.8)
I would also recommend that you use a virtualenv if you need specific versions libraries installed for your project.
virtualenv venv
source venv/bin/activate
pip install pip --upgrade

pip refuses to upgrade

I currently have installed pip 8.1.2.
So I want to upgrade it to the latest version (9.0.1) and I execute:
sudo pip install --upgrade pip
Collecting pip
Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
100% |████████████████████████████████| 1.3MB 846kB/s
Installing collected packages: pip
Found existing installation: pip 8.1.2
Not uninstalling pip at /usr/lib/python2.7/dist-packages, outside environment /usr
Successfully installed pip-8.1.2
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
It seems that it correctly downloads 9.0.1 but then it refuses to uninstall the existing installation (8.1.2)
And then at the end it suggests me to upgrade using the same exact instruction I already provided!
Am I doing anything wrong?
The Ubuntu pip version has been patched to prevent self-upgrades (all installation into system-managed files are prevented, the patch is named hands-off-system-packages.patch). You are supposed to use the Ubuntu packaging system to upgrade instead. The feedback provided could be improved certainly.
As there is no Ubunutu package of pip 9.0.1 available yet for your Ubuntu version, you can't actually upgrade to a newer version this way (there is a version for Zesty however).
A (ugly) work-around is to use easy_install instead:
sudo easy_install -U pip
This works because easy_install has not been booby-trapped to prevent the upgrade. However, this'll replace system managed files with the newer pip version. If your package manager were to re-install the python-pip package, it'll happily overwrite those files and you could in theory end up with a broken installation. Also, easy_install adds more files than the package would, and those extra files could cause issues later down the line, especially when you upgrade python-pip later when a new version is packaged.
If you were to use a virtualenv, you are free to upgrade pip inside that, which works just fine.
If above are not working, please try this it works(I had similar situations and this works):
download get-pip.py:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
Run the downloaded file: python get-pip.py
Above uninstalls the old version and install the latest ones.
Reference Link: https://pip.pypa.io/en/stable/installing/#installing-with-get-pip-py
Had a similar issue with pip not wishing to upgrade, though I'm not keen on replacing the package manager's version and as I'm always adding the --user option on installations via pip I figured "what's the harm?" in doing the same with pip on itself.
pip install --user --upgrade pip
It'll only work for one user but for some use cases that is just peachy.

How can I let pip know that I am interested in packages for python 3.4?

After an hour search, I have found no answer.
My Mac came with Python 2.7, but I have decided to upgrade to python 3.4.
I installed python 3.4 from python.org.
I can now use python 3.4 from terminal.
Pip still tries to download python 2.7 packages - numpy for 2.7 is "up to date".
When I try to --upgrade a package, for example numpy, I get "no permission" error. With sudo appended, the output is trash.
How can I let pip know that I am interested in packages for python 3.4?
Requirement already up-to-date: numpy in /Library/Python/2.7/site-packages
That's the problem. I want numpy to be up-to-date with Python 3.4.
You should be able to call a specific pip for your install, although it depends on which version you are running:
Starting at version 0.8:
pip-3.4 install numpy
and starting at version 1.5:
pip3.4 install numpy
If you don't have these, you should be able to just download pip and reinstall it, just be sure to call python 3.4 when you run the installer.
I would suggest to install a package manager such as macports brew and install the updated python version from them. After the latest version of python is setup use pip to install the version of numpy
In mac ports , you are able to select the default system python without messing with the path your self.
I would use Homebrew:
brew install python3
This should install Python3.4.1. Then to get pip:
curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
sudo python3 get-pip.py
# Upgrade just in case...
pip3 install -U pip
Then use:
pip3 install numpy
And to run Python, use:
python3
(I only have one Python 3 installation, if you have multiple you'll need to be more specific with the version number)

How to Uninstall setuptools python

Hi recently i installed setup tools module and google app engine gives me errors . Is there a way to uninstall setuptool? can any one tell me step by step because i tried hard
The answer depends on how it was installed.
If it was installed using the ubuntu (debian) package manager, try:
sudo apt-get remove --purge python-setuptools
[updated]
If you installed manually, probably the setuptools final location will be something like (adjust for your environment/python version):
/usr/local/lib/python2.6/dist-packages
Just delete the setuptools stuff there.
Lame, I know, but it is your burden for not using the excellent package manager provided by ubuntu: stick to dpkg unless you need bleeding edge stuff. For other python modules installed by setuptools, it provides no "uninstall" feature (but pip does, that is why there is a lot of enthusiasm around virtualenv, pip and yolk).
[2017 update]
It is 2017 and installing Python modules changed a bit:
pip is now the preferred installer program. Starting with Python 3.4, it is included by default with the Python binary installers.
venv is the standard tool for creating virtual environments (semi-isolated Python environments that allow packages to be installed for use by a particular application, rather than being installed system wide), and has been part of Python since Python 3.3. Starting with Python 3.4, it defaults to installing pip into all created virtual environments.
virtualenv is a third party alternative (and predecessor) to venv and if not official it is still very popular because it allows virtual environments to be used on versions of Python prior to 3.4, which either don’t provide venv at all, or aren’t able to automatically install pip into created environments.
easy_install pip
pip uninstall pip setuptools
(pip and setuptools both use the same package formats, but pip has uninstall support. kinda hilarious that installing something is the easiest way to uninstall.)
I was having trouble with the method below because my pip wasn't up to date.
easy_install pip
pip uninstall pip setuptools
After upgrading pip like this:
sudo -H pip install --upgrade pip
I was able to successfully uninstall setuptools like so:
pip uninstall setuptools

Categories