I do have Python version 3.8.2 and an outdated version of PIP. I am using a Mac, and when I try to upgrade PIP by doing pip install --upgrade pip I'm getting this error message:
➜ ~ pip install --upgrade pip
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3241, in <module>
#_call_aside
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3225, in _call_aside
f(*args, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 3254, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 585, in _build_master
return cls._build_from_requirements(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 598, in _build_from_requirements
dists = ws.resolve(reqs, Environment())
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources/__init__.py", line 786, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pip==18.0' distribution was not found and is required by the application
➜ ~ ```
pip runs the 2.7 pip. Look at the traceback. pip3 runs a 3.x pip, and if 3.8 is the only one, 3.8. python3 -m pip will run some 3.x pip and python3.8 -m pip will only run 3.8 pip. I recommend that you first upgrade to 3.8.7. I forget whether the python.org installer has an option to upgrade pip with it. If not,
python3.8 -m pip install --upgrade pip
should work (I just ran it). If not
python3.8 -m ensurepip
should install a recent pip which can be upgraded.
You will have to reinstall pip manually by following the steps here described.
Donwload get-pip.py
Run python get-pip.py in the folder you downloaded the python script to.
Then, you can use pip normally.
Related
$ sudo easy_install pip ( on mac high sierra)
Traceback (most recent call last):
File "/usr/bin/easy_install-2.7", line 11, in <module>
load_entry_point('setuptools==18.5', 'console_scripts', 'easy_install')()
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 484, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 2707, in load_entry_point
return ep.load()
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 2325, in load
return self.resolve()
File "/Library/Python/2.7/site-packages/pkg_resources/__init__.py", line 2331, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/command/easy_install.py", line 46, in <module>
from setuptools.archive_util import unpack_archive
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/archive_util.py", line 15, in <module>
from pkg_resources import ensure_directory, ContextualZipFile
ImportError: cannot import name ContextualZipFile
$ which python
/usr/bin/python
$ which pip
/usr/local/bin/pip
$ which python3
/usr/local/bin/python3
You should try firstly installing pip by using these commands:
sudo apt update
sudo apt install python3-pip
If you are installing it for python2:
sudo apt update
sudo apt install python-pip
Then you can verify the version using:
pip3 --version
Hope this helps.
Here you are having two versions of python installed on your mac.
First is the Python 2.x (which is default) and Python 3.x.
This is a problem I too faced a lot earlier, so what I suggest is this
$sudo apt install python3-pip
This will explicitly install the pip for Python 3.x
And once completed use a virtual environment.
I'm on OS X El Capitan 10.11.6 with homebrew installed python 2.7. I've removed and re-installed python via homebrew with no joy. pip can neither install site-packages or update itself.
Trying to upgrade pip and receive the following error:
$ pip install --upgrade pip
Collecting pip
Using cached pip-9.0.1-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 8.1.2
Uninstalling pip-8.1.2:
Successfully uninstalled pip-8.1.2
Rolling back uninstall of pip
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/site-packages/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File "/usr/local/lib/python2.7/site-packages/pip/req/req_set.py", line 742, in install
**kwargs
File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 831, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/usr/local/lib/python2.7/site-packages/pip/req/req_install.py", line 1032, in move_wheel_files
isolated=self.isolated,
File "/usr/local/lib/python2.7/site-packages/pip/wheel.py", line 463, in move_wheel_files
generated.extend(maker.make(spec))
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.py", line 372, in make
self._make_script(entry, filenames, options=options)
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.py", line 276, in _make_script
self._write_script(scriptnames, shebang, script, filenames, ext)
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/distlib/scripts.py", line 250, in _write_script
self._fileop.write_binary_file(outname, script_bytes)
File "/usr/local/lib/python2.7/site-packages/pip/_vendor/distlib/util.py", line 405, in write_binary_file
with open(path, 'wb') as f:
IOError: [Errno 1] Operation not permitted: '/bin/pip'
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.
Found the answer here: Python: pip tries to install to /bin directory
I had a .pydistutils.cfg file in my home directory that was a workaround for something else (I forget what) and once removed it solved all my pip problems.
I have run into this numerous times on my current project and it's driving me crazy. I discover I need to install some module but get an error that pip 6.1.1 isn't installed (server has 8.1.2):
$ sudo pip install djangorestframework
Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2991, in <module>
#_call_aside
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2977, in _call_aside
f(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3004, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 664, in _build_master
return cls._build_from_requirements(__requires__)
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 677, in _build_from_requirements
dists = ws.resolve(reqs, Environment())
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 856, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pip==6.1.1' distribution was not found and is required by the application
so I checked:
$ pip --version
pip 8.1.2 from /usr/local/lib/python2.7/site-packages (python 2.7)
I have tried $ sudo yum install djangorestframework but the package doesn't exist (no surprise). how do install these things that seem to rely specifically on 6.1.1 but I have 8.1.2? I'm worried if I uninstall (and rollback) that I'll loose functionality in other areas...
It occurred to me it's a difference between the sudo in the first command and lack of it in the second, so I tried this:
$ sudo yum install python-pip
Loaded plugins: priorities, update-motd, upgrade-helper
Package python26-pip-6.1.1-1.23.amzn1.noarch already installed and latest version
Nothing to do
[ec2-user#ip-172-XX-XX-XXX limboproj]$ source limboenv/bin/activate
(limboenv)[ec2-user#ip-172-XX-XX-XXX limboproj]$ sudo yum install python-pip
Loaded plugins: priorities, update-motd, upgrade-helper
amzn-main/latest | 2.1 kB 00:00
amzn-updates/latest | 2.3 kB 00:00
Package python26-pip-6.1.1-1.23.amzn1.noarch already installed and latest version
Nothing to do
and I still get:
$ sudo pip --version
Traceback (most recent call last):
File "/usr/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2991, in <module>
#_call_aside
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2977, in _call_aside
f(*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 3004, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 664, in _build_master
return cls._build_from_requirements(__requires__)
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 677, in _build_from_requirements
dists = ws.resolve(reqs, Environment())
File "/usr/local/lib/python2.7/site-packages/pkg_resources/__init__.py", line 856, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pip==6.1.1' distribution was not found and is required by the application
SO labelled as a duplicate, so I'm including here my comment below. when I tried to follow the answer on the suggested question, I got:
$ sudo pip install --upgrade pip-6.1.1
which results in a stacktrace ending with:
The 'pip==6.1.1' distribution was not found and is required by the application. also notice in my edit, i show that sudo yum install python-pip seems to conflict with sudo pip --version
not sure how to really resolve what I was dealing with, but it turns out the project's virtualenv had a satisfactory version of pip. for people in the future, try to activate the virtual env:
$ source projectenv/bin/activate
and then install
$ sudo pip install djangorestframework
That worked great for me
Using OSX El Capitan. Just installed a bunch of pip module and was following a few online tutorials, must have broken something as now I get the following error whenever I try to use pip (although python seems to run fine).
$ pip install pandas
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 2837, in <module>
File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 451, in _build_master
File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 464, in _build_from_requirements
File "build/bdist.macosx-10.9-x86_64/egg/pkg_resources.py", line 639, in resolve
pkg_resources.DistributionNotFound: pip==1.5.6
Any helping fixing would be much appreciated.
Thanks.
Reinstall using easy_install. Close the terminal and reopen. Pip should now work.
Try updating pip first by typing pip install -U pip and the try pip install pandas. I myself use Anaconda/Miniconda. Most of the packages are well handled and the dependencies are taken care of as well by the conda package manager.
I am having a problem with pip just now, when I try to install something like pip install readline then I get an error:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 9, in <module>
load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 549, in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2709, in load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2369, in load
File "build/bdist.linux-x86_64/egg/pkg_resources/__init__.py", line 2375, in resolve
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 74, in <module>
from pip.vcs import git, mercurial, subversion, bazaar # noqa
File "/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in <module>
from pip.download import path_to_url
File "/usr/lib/python2.7/dist-packages/pip/download.py", line 25, in <module>
from requests.compat import IncompleteRead
ImportError: cannot import name IncompleteRead
So I ran cat /usr/local/bin/pip which tells me pip==1.5.6. I tried to find a solution online regarding this and one solution told to cd /usr/local/lib/python2.7/site-packages && ls but for me I see that folder is also empty.
If upgrading pip doesn't work, you should try uninstalling it and reinstalling it. The error you're encountering is likely due to a mismatch in versions between pip and requests. First, I would remove pip and reinstall it from the source with python like this:
sudo apt-get remove python-pip
wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
From the Ubuntu launchpad site
Just check If You have installed python-setuptools rpm, If this is installed You can use easy_install pip on Redhat Based System.
I would comment this but due to low reputation I can't. Did you try upgrading pip?
pip install --upgrade pip
And then try to do that again.
If you are using Debian flavor OS (like Ubuntu) try this
apt-get remove python-pip
Then try to install the latest version by easy_install
easy_install pip