When I try to import matplotlib I get an error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/matplotlib/__init__.py", line 128, in <module>
from matplotlib.rcsetup import defaultParams, validate_backend, cycler
File "/usr/local/lib/python2.7/dist-packages/matplotlib/rcsetup.py", line 29, in <module>
from matplotlib.fontconfig_pattern import parse_fontconfig_pattern
File "/usr/local/lib/python2.7/dist-packages/matplotlib/fontconfig_pattern.py", line 32, in <module>
from backports.functools_lru_cache import lru_cache
ImportError: No module named functools_lru_cache
backports itself imports properly. When I try to install functools manually via
sudo pip install backports.functools_lru_cache
I get info that
Requirement already satisfied: backports.functools_lru_cache in /usr/local/lib/python2.7/dist-packages
Nevertheless when i try to
import backports.functools_lru_cache
I get info that
ImportError: No module named functools_lru_cache
System info
Ubuntu 16
Python 2.7.12
Pip 9.0.1
If someone is still having that problem and reinstalling backports.functools_lru_cache do not work in his case, as it was in my case, then probably installing older version of matplotlib would work. For example:
pip install matplotlib==2.0.2
Problem occurred for version 2.2.0, I switched to 2.0.2 and it is working now. I did not check other versions.
I had the same problem but I fixed it.
Uninstall first
pip uninstall backports.functools_lru_cache
and then re-install it.
pip install backports.functools_lru_cache
Now I'm able to import matplotlib. Hope this helps.
Install arrow using:
pip install arrow==0.12.0
fixed this issue for me
The pip command was actually the pip3, and the "ImportError" was happening when I used python (2.7).
pip2 uninstall backports.functools_lru_cache
then,
pip2 install backports.functools_lru_cache
fixed my problem.
You have to check what is the import path of backports package:
import backports
print('Backports Path: {0}'.format(backports.__path__))
1. The import path is the main python path ( the case of Matimath's question)
pip uninstall backports.functools_lru_cache (this will uninstall it from /usr/local/)
pip install backports.functools_lru_cache
2. The import path is the local usr dir (~/.local/, or %APPDATA%\Python for windows)
pip uninstall backports.functools_lru_cache
pip install --user backports.functools_lru_cache
Use pip2 command for python2.
The reason for this inconsistency is that the import path of backports package might have been changed during another module/package installation (eg. from backports.configparser module) - see here for more details:
https://bugs.python.org/issue31741
Following from Aditya Jain's answer,
[python -m] pip uninstall backports.functools_lru_cache
[python -m] pip install backports.functools_lru_cache==1.2.1
which will avoid installing arrow merely to downgrade functools_lru_cache.
I had the same problem and my solution was;
Download whl file from https://pypi.python.org/pypi/backports.functools_lru_cache/1.3
pip install
I solved my problem by removing the excessive matplotlib packages. I found out that when importing matplotlib it was attempting to import backports.functools_lru_cache and there it was throwing the Importerror.
I realized that I had different matplotlib packages in many locations:
/usr/lib/python2.7/dist-packages/matplotlib/
/usr/lib/python2.7/site-packages/matplotlib/
I removed the site-packages one. I left the dist-packages one intact.
Then I ran the following commands in python:
matplotlib.get_configdir()
matplotlib.get_cachedir()
and I removed the matplotlib packages in the output paths of these commands.
Then I removed the matplotlib in my virtualenvironment:
mv /home/username/virtualenvironment/lib/python2.7/matplotlib* /tmp
Finally I removed the one in the .local folder:
mv /home/username/.local/lib/python2.7/matplotlib* /tmp
Now importing matplotlib works fine. So when I run in python:
matplotlib.__file__
it returns
'/usr/lib/python2.7/dist-packages/matplotlib/__init__.pyc'
Now it does not throw error anymore when import backports.functools_lru_cache
You are using pyhton 2. try to use pip2 instead:
pip2 uninstall matplotlib
sudo apt-get autoremove python-matplotlib
sudo apt-get install python-matplotlib
If you're experiencing this issue on Ubuntu 18.x (and maybe other versions): it is caused by this Ubuntu bug. The problem is in the Ubuntu package python-configparser which is installed as a dependence of python-pip. It contains empty __init__ file
/usr/lib/python2.7/dist-packages/backports/__init__.py
Hence, pip modules installed to /usr/local/lib/python2.7/dist-packages/backports are simply ignored. As soon as this bug is not fixed yet, the easiest way to fix this is to remove this package:
sudo apt remove python-configparser
It does not any harm to any of your backports modules installed by pip (since they are in another folder), and this is much safer than version downgrade.
See also this pip issue with similar problem around backports module.
I had same issue, re-installation of backports.functools_lru_cache resolved the issue
Also meet this issue on Ubuntu 16.
Uninstall & reinstall not work for me.
My solution is reinstall from apt.
pip uninstall matplotlib
sudo apt-get autoremove python-matplotlib
sudo apt-get install python-matplotlib
This worked for me. Ubuntu 18.04.
sudo pip2 uninstall backports.functools-lru-cache
sudo apt install python-backports.functools-lru-cache
this worked for me
from backports.functools_lru_cache import lru_cache
Related
So recently I had to reinstall python due to corrupt executable. This made one of our python scripts bomb with the following error:
AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK'
The line of code that caused it to bomb was:
from apiclient.discovery import build
I tried pip uninstalling and pip upgrading the google-api-python-client but I cant seem to find any information on this particular error.
For what it is worth - I am trying to pull google analytics info down via API call.
here is an output of the command prompt error
File "C:\Analytics\Puritan_GoogleAnalytics\Google_Conversions\mcfTest.py", line 1, in <module>
from apiclient.discovery import build
File "C:\ProgramData\Anaconda3\lib\site-packages\apiclient\__init__.py", line 3, in <module>
from googleapiclient import channel, discovery, errors, http, mimeparse, model
File "C:\ProgramData\Anaconda3\lib\site-packages\googleapiclient\discovery.py", line 57, in <module>
from googleapiclient import _auth, mimeparse
File "C:\ProgramData\Anaconda3\lib\site-packages\googleapiclient\_auth.py", line 34, in <module>
import oauth2client.client
File "C:\ProgramData\Anaconda3\lib\site-packages\oauth2client\client.py", line 45, in <module>
from oauth2client import crypt
File "C:\ProgramData\Anaconda3\lib\site-packages\oauth2client\crypt.py", line 45, in <module>
from oauth2client import _openssl_crypt
File "C:\ProgramData\Anaconda3\lib\site-packages\oauth2client\_openssl_crypt.py", line 16, in <module>
from OpenSSL import crypto
File "C:\ProgramData\Anaconda3\lib\site-packages\OpenSSL\__init__.py", line 8, in <module>
from OpenSSL import crypto, SSL
File "C:\ProgramData\Anaconda3\lib\site-packages\OpenSSL\crypto.py", line 1517, in <module>
class X509StoreFlags(object):
File "C:\ProgramData\Anaconda3\lib\site-packages\OpenSSL\crypto.py", line 1537, in X509StoreFlags
CB_ISSUER_CHECK = _lib.X509_V_FLAG_CB_ISSUER_CHECK
AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK'
Edit the crypto.py file mentioned in the stacktrace and remove the offending line by commenting it out with a #
Then upgrade latest version of PyOpenSSL.
pip install pip --upgrade
pip install pyopenssl --upgrade
Now you can re-add the commented line again and it should be working
As all the above failed for me i used the trick here: https://askubuntu.com/a/1433089/497392
sudo apt remove python3-pip
wget https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py
And then after a reboot:
pip install pyopenssl --upgrade
pip3 install pyOpenSSL --upgrade
solved all my issues.
on my ubuntu "20.04.5" I manage solving the error:
CB_ISSUER_CHECK = _lib.X509_V_FLAG_CB_ISSUER_CHECK\r
by re-installing the following packages:
apt-get --reinstall install python-apt
apt-get --reinstall install apt-transport-https
apt-get install build-essential libssl-dev libffi-dev python-dev
I do not use pip as I received this error message using ansible playbook and wasn't able to reach the servers anymore.
Hope it helps somebody on day.
For me, earlier answers can't help me as I meet this problem for all pip commands, even pip3 -V. But I solved it by:
wget https://files.pythonhosted.org/packages/00/3f/ea5cfb789dddb327e6d2cf9377c36d9d8607af85530af0e7001165587ae7/pyOpenSSL-22.1.0-py3-none-any.whl (get url from https://pypi.org/project/pyOpenSSL/#files if you need the latest version)
python3 -m easy_install pyOpenSSL-22.1.0-py3-none-any.whl
Thanks https://askubuntu.com/a/1429674
I also encountered this error while installing Flask and firebase-admin on Ubuntu 20.04. The following commands solved my problem.
First I removed OpenSSL using this command.
sudo rm -rf /usr/lib/python3/dist-packages/OpenSSL
sudo pip3 install pyopenssl
sudo pip3 install pyopenssl --upgrade
Below commands worked for me...
sudo pip3 install pyopenssl
sudo pip3 install pyopenssl --upgrade
I stumbled into this problem this morning trying to install weasyprint after a system update and restart. Commenting out the line containing
X509_V_FLAG_CB_ISSUER_CHECK
in /usr/lib/python3/dist-packages/OpenSSL/crypto.py resulted in a further error
AttributeError: module 'lib' has no attribute 'OpenSSL_add_all_algorithms'
None of the suggested fixes would work for me.
sudo apt remove python3-pip followed by sudo apt install python3-pip
sudo pip install pyopenssl --upgrade
sudo python3 -m easy_install pyOpenSSL-22.0.0-py2.py3-none-any.whl
sudo pip install --force-reinstall "cryptography==38.0.4"
I found this module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK' but it didn't add to anything I already knew. I found this AttributeError: module 'lib' has no attribute 'OpenSSL_add_all_algorithms' but it comes with WARNINGS for people running on desktops and it causing significant system wide issues.
I tried upgrading OpenSSL via easy_install but the wheel could not be found and there was a depreciation warning. Eventually I came back to the comment by #Alexandr who said just remove OpenSSL with rm.
sudo rm -rf /usr/lib/python3/dist-packages/OpenSSL
From here I attempted to reinstall OpenSSL but found it was already statisfied. Maybe an older package was blocking and this was the root of the problem?
sudo pip install pyopenssl
Requirement already satisfied: pyopenssl in /usr/lib/python3/dist-packages (19.0.0)
I then upgraded pip and was able to install WeasyPrint which I hope confirms I have solved this issue.
pip install pip --upgrade
Successfully installed pip-22.3.1
pip install weasyprint
Successfully installed Pyphen-0.13.2 ... weasyprint-57.2 zopfli-0.2.2
sudo apt remove python3-openssl
If you have pip completely broken, as #sgdesmet propose in a comment, the only option to resolve this issue is
"Edit the crypto.py file and remove the offending line by commenting it out with a #"
No other solutions work with me.
If pip / pip3 is completely broken and nothing of the other option work (as described by #DarkSkull), then the line in the crypto.py file that's causing the issue has to be deleted or commented out.
Here's an automated way of doing it:
python_openssl_crypto_file="/usr/lib/python3/dist-packages/OpenSSL/crypto.py"
search_term="CB_ISSUER_CHECK = _lib.X509_V_FLAG_CB_ISSUER_CHECK"
cb_issuer_check_line_number="$(awk "/$search_term/ {print FNR}" $python_openssl_crypto_file)"
sed -i "${cb_issuer_check_line_number}s/.*/ # $search_term/" $python_openssl_crypto_file
I've tried upgrading pip and installing another version of pyOpenSSL from whl file, but that didn't work. The only thing that helped is removing the entire folder with OpenSSL module like that rm -rf ...python-3.8.10/lib/python3.8/site-packages/OpenSSL and then doing all the thing you need.
Thanks to the answers above I was able to solve the same problem. I use pipenv to manage my environment. The issue arose after upgrading my cryptography module.
The fix (for me):
pipenv update pyOpenSSL
I have successfully installed the bitarray package, because I can find it after the command: pip list.
But when I try to import it I get :
>>> from bitarray import bitarray
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
from bitarray import bitarray
ModuleNotFoundError: No module named 'bitarray'
What can I try to solve it ?
I'm using Ubuntu 18.04.5 .
You can install package as python3 -m pip install bitarray. May be when you did pip install bitarray, it install your package for python2.
Ubuntu comes with two python versions. If you just ran pip install x it installed it into python 2.7. You're probably using python3, so you wanna install with pip3 install x
Just to make sure you are running correct pip, try running "pip -V" or "pip --version", it gives you which version of python it refers to. In terminal it looks something like this pip version check
Its also possible that you might have pip for say python 2.7, pip3 for python 3.6, and pip3.7 for python 3.7, if you have multiple versions of python installed.
For simplicity you can set the most frequently used pip version as pip by setting an alias in ~/.bashrc. This is done by adding the following line in bashrc:
alias pip=pip3.6.
After this you can try and install the packages and import it swiftly.
I have Python 2.6 in my Linux rhel-5. I have installed pip and required CFFI packages. When I try to run a sample CFFI program:
ffi = FFI()
it says:
File "/usr/lib/python2.6/site-packages/cffi/api.py", line 56, in __init__
import _cffi_backend as backend
ImportError: No module named _cffi_backend
What could be the possible error? Did I miss something during installation? I have installed pip, wheel, pycparser, pytest and cffi.
For python2.x use following command:
python -m pip install cffi
for python3.x
python3 -m pip install cffi
I needed to uninstall and install it again:
sudo pip uninstall cryptography
sudo pip uninstall paramiko
then install pagamiko again
sudo pip install paramiko
and it start to work for me
I recently had the same issue and none of the above solutions worked for me.
Here is what worked.
sudo apt remove python3-cffi
sudo python3 -m pip install cffi
Did you compile Python from source, and if so, did it give you any errors during the configure/make/make install phase? Compiling Python from source can be a real beast on older Red Hat systems, so if you installed that way, I'd suggest combing through the configure and make output to be sure that no modules were left out.
In order to get pip install cffi to succeed with no errors, I had to install gcc and libffi-devel from the EL5 repos. From there, I was able to instantiate an FFI instance with no problems:
>>> from cffi import FFI
>>> ffi = FFI()
>>>
Here's the output of pip freeze, for reference:
[root#machine ~]# pip freeze
argparse==1.2.1
autobahn==0.8.10
cffi==1.5.2
characteristic==14.3.0
pika==0.9.13
pyasn1==0.1.7
pyasn1-modules==0.0.8
pycparser==2.14
pycrypto==2.6.1
pyOpenSSL==0.12
pysnmp==4.2.5
requests==2.7.0
service-identity==14.0.0
six==1.7.3
Twisted==14.0.0
version-utils==0.2.2
wheel==0.24.0
zope.interface==4.1.1
If you've got the same or better versions of the relevant packages installed, I'd try a pip -vvv install --upgrade --force-reinstall cffi, just to see if there are perhaps errors that pip was masking, and go from there.
I had the same problem, following this thread https://github.com/pyca/cryptography/issues/4403, I solved the problem by reinstalling and upgrading with the command:
pip install -U cffi
You have to first remove the following packages:
cryptography
bcrypt
paramiko
Now use the following command to install:
pip -vvv install --upgrade --force-reinstall cffi
Have the same problem. After many attempts adding import cffi solve the issue.
Make sure you have cffi and cryptography installed.
You could look at the code L56 in /usr/lib/python2.6/site-packages/cffi/api.py
It needs the _cffi_backend.so in your pythonpath. You could install the python-cffi for it. But not sure whether it is in your RPM repo, especially you are using RHEL-5.
Here is an RPM for CENTOS http://cbs.centos.org/koji/rpminfo?rpmID=20613
Hope it helps. I am still searching the source code for building the _cffi_backend.so.
For me there was no way to install cffi on python3.8 because of this:
ImportError: cannot import name 'sysconfig' from 'distutils' (/usr/lib/python3.8/distutils/__init__.py)
Somehow, the package python3-distutils does not exist in Ubuntu 16.04.
So I ended up installing python3.7 and now I finally could install cffi, fixing the problem mentioned by the TS.
You should install cffi via pip install cffi
to get the latest version. I had to restart my application for it to recognize the cffi installation.
I was getting this error while trying to get the cryptography module to work with Python 3.8 for AWS Lambda.
Adding the cffi*manylinux*.whl files to my Lambda Layer (as suggested here) worked.
The cffi module comes built in for many python distributions, but not on AWS Lambda
For AWS Lambda I was facing the same issue when running on Python3.7. When I downgraded it to Python3.6, this issue was resolved.
I think this packaged might have been present in Python3.6 version and later was removed. Adding this package while making layers for AWS Lambda might resolve the problem for Python3.7.
I encountered this issue when trying to install packages in a local directory using pip install -t . and then running python (2.7). My solution was to remove the -t and not install into a local directory.
it worked after adding " import cffi " in my application.
please refer for more details.
https://buildmedia.readthedocs.org/media/pdf/cffi/latest/cffi.pdf
Thanks to #MPlanchard, for his answer which helped identify the cause
In my case, the issue was related to python3.9, changing to python3.8 it just works well!
After many futile efforts to install the right packages, the right python versions and building the perfect layer, resorting to installing Fabric solved it for me
I got this issue running an Ansible playbook using python 3.9 under Ubuntu-18.04 in WSL2. It was sorted by doing:
sudo apt-get remove -y python3-cffi-backend
sudo apt-get install -y python3-cffi-backend
I am trying to pip install the MySQL-python package, but I get an ImportError.
Jans-MacBook-Pro:~ jan$ /Library/Frameworks/Python.framework/Versions/3.3/bin/pip-3.3 install MySQL-python
Downloading/unpacking MySQL-python
Running setup.py egg_info for package MySQL-python
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/var/folders/lf/myf7bjr57_jg7_5c4014bh640000gn/T/pip-build/MySQL-python/setup.py", line 14, in <module>
from setup_posix import get_config
File "./setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 16, in <module>
File "/var/folders/lf/myf7bjr57_jg7_5c4014bh640000gn/T/pip-build/MySQL-python/setup.py", line 14, in <module>
from setup_posix import get_config
File "./setup_posix.py", line 2, in <module>
from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
----------------------------------------
Command python setup.py egg_info failed with error code 1 in /var/folders/lf/myf7bjr57_jg7_5c4014bh640000gn/T/pip-build/MySQL-python
Storing complete log in /Users/jan/.pip/pip.log
Jans-MacBook-Pro:~ jan$
Any ideas?
You can instead use the mysqlclient package as a drop-in replacement for MySQL-python. It is a fork of MySQL-python with added support for Python 3.
I had luck with simply
pip install mysqlclient
in my python3.4 virtualenv after
sudo apt-get install python3-dev libmysqlclient-dev
which is obviously specific to ubuntu/debian, but I just wanted to share my success :)
In Python 3, ConfigParser has been renamed to configparser for PEP 8 compliance. It looks like the package you are installing does not support Python 3.
Here is a code that should work in both Python 2.x and 3.x
Obviously you will need the six module, but it's almost impossible to write modules that work in both versions without six.
try:
import configparser
except:
from six.moves import configparser
pip install configparser
sudo cp /usr/lib/python3.6/configparser.py /usr/lib/python3.6/ConfigParser.py
Then try to install the MYSQL-python again.
That Worked for me
MySQL-python is not supported on python3 instead of this you can use mysqlclient
If you are on fedora/centos/Red Hat install following package
yum install python3-devel
pip install mysqlclient
Additional info:
Python 2x
import ConfigParser
Python 3x
import configparser
Compatibility of Python 2/3 for configparser can be solved simply by six library
from six.moves import configparser
If you are using CentOS, then you need to use
yum install python34-devel.x86_64
yum groupinstall -y 'development tools'
pip3 install mysql-connector
pip install mysqlclient
I was having the same problem. Turns out, I needed to install python3 devel on my centos. First, you need to search for the package that is compatible with your system.
yum search python3 | grep devel
Then, install the package as:
yum install -y python3-devel.x86_64
Then, install mysqlclient from pip
pip install mysqlclient
Do pip3 install PyMySQL and then pip3 install mysqlclient.
Worked for me
I got further with Valeres answer:
pip install configparser
sudo cp /usr/lib/python3.6/configparser.py /usr/lib/python3.6/ConfigParser.py
Then try to install the MYSQL-python again. That Worked for me
I would suggest to link the file instead of copy it. It is save to update. I linked the file to /usr/lib/python3/ directory.
For me the following command worked:
sudo python3 -m pip install mysql-connector
Try this solution which worked fine for me.
Basically it's to reinstall/upgrade to latest version of mysql from brew, and then installing mysqlclient or MySQL-Python from global pip3 instead of virtualenv pip3.
Then accessing the virtualenv and successfully install mysqlclient or MySQL-Python.
I still have this issue, so I go to /usr/lib/python3.8 and type as sudoer:
cp configparser.py ConfigParser.py
You may have another python version than 3.8.
Following #MaciejNg I tried making a copy, which didn't work:
sudo cp ./env/lib/python3.8/site-packages/configparser.py ./env/lib/python3.8/site-packages/ConfigParser.py
Because configparser.py and ConfigParser.py are identical, I renamed the file:
sudo mv ./env/lib/python3.8/site-packages/configparser.py ./env/lib/python3.8/site-packages/ConfigParser.py
how about checking the version of Python you are using first.
import six
if six.PY2:
import ConfigParser as configparser
else:
import configparser
I run kali linux- Rolling and I came across this problem ,when I tried running cupp.py in the terminal, after updating to python 3.6.0. After some research and trial I found that changing ConfigParser to configparser worked for me but then I came across another issue.
config = configparser.configparser()
AttributeError: module 'configparser' has no attribute 'configparser'
After a bit more research I realised that for python 3 ConfigParser is changed to configparser but note that it has an attribute ConfigParser().
I was getting the same error on Mac OS 10, Python 3.7.6 & Django 2.2.7. I want to use this opportunity to share what worked for me after trying out numerous solutions.
Steps
Installed Connector/Python 8.0.20 for Mac OS from link
Copy current dependencies into requirements.txt file, deactivated the current virtual env, and deleted it using;
create the file if not already created with; touch requirements.txt
copy dependency to file; python -m pip3 freeze > requirements.txt
deactivate and delete current virtual env; deactivate && rm -rf <virtual-env-name>
Created another virtual env and activated it using; python -m venv <virtual-env-name> && source <virtual-env-name>/bin/activate
Install previous dependencies using; python -m pip3 install -r requirements.txt
base on your OS is centos use python3
if you don't known where is configparser.py or ConfigParser.py
pip3 install configparser
find / -name "configparser.py"
cd /usr/local/lib/python3.6/site-packages(base on your environment )
cp configparser.py ConfigParser.py
solved the issue
Kindly to see what is /usr/bin/python pointing to
if it is pointing to python3 or higher change to python2.7
This should solve the issue.
I was getting install error for all the python packages. Abe Karplus's solution & discussion gave me the hint as to what could be the problem.
Then I recalled that I had manually changed the /usr/bin/python from python2.7 to /usr/bin/python3.5, which actually was causing the issue. Once I reverted the same. It got solved.
This worked for me
cp /usr/local/lib/python3.5/configparser.py /usr/local/lib/python3.5/ConfigParser.py
Whenever i try to use pip I get an error. For exampple:
$ sudo pip install gevent-websocket
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2675, in <module>
parse_requirements(__requires__), Environment()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 552, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pip==0.8.1
I feel tempted to change the value of into pip==0.8.2.. but I dont feel dealing with the consequences of 'hacking' up my installation...
I'm running python 2.7 and pip is at version 0.8.2.
I find this problem in my MacBook, the reason is because as #Stephan said, I use easy_install to install pip, and the mixture of both py package manage tools led to the pkg_resources.DistributionNotFound problem.
The resolve is:
easy_install --upgrade pip
Remember: just use one of the above tools to manage your Py packages.
I replaced 0.8.1 in 0.8.2 in /usr/local/bin/pip and everything worked again.
__requires__ = 'pip==0.8.2'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('pip==0.8.2', 'console_scripts', 'pip')()
)
I installed pip through easy_install which probably caused me this headache.
I think this is how you should do it nowadays..
$ sudo apt-get install python-pip python-dev build-essential
$ sudo pip install --upgrade pip
$ sudo pip install --upgrade virtualenv
I had this issue when I was using homebrew. Here is the solution from Issue #26900
python -m pip install --upgrade --force pip
Try re-installing with the get-pip script:
wget https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py
This is sourced from the pip Github page, and worked for me.
If you're on CentOS make sure you have the YUM package "python-setuptools" installed
yum install python-setuptools
Fixed it for me.
The root of the problem are often outdated scripts in the bin (Linux) or Scripts (Windows) subdirectory. I'll explain this using problem I encountered myself as an example.
I had virtualenv version 1.10 installed in my user site-packages (the fact it's in user site-packages not sytem site-packages is irrelevant here)
pdobrogost#host:~$ which virtualenv
/home/users/pdobrogost/.local/bin/virtualenv
pdobrogost#host:~$ virtualenv --version
1.10
After I upgraded it to version 1.11 I got the following error:
pdobrogost#host:~$ virtualenv --version
Traceback (most recent call last):
File "/home/users/pdobrogost/.local/bin/virtualenv", line 5, in <module>
from pkg_resources import load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 2701, in <module>
return self.__dep_map
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 572, in resolve
if insert:
pkg_resources.DistributionNotFound: virtualenv==1.10
File /home/users/pdobrogost/.local/bin/virtualenv mentioned in the error message looked like this:
#!/opt/python/2.7.5/bin/python2.7
# EASY-INSTALL-ENTRY-SCRIPT: 'virtualenv==1.10','console_scripts','virtualenv'
__requires__ = 'virtualenv==1.10'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('virtualenv==1.10', 'console_scripts', 'virtualenv')()
)
There, we see that virtualenv script was not updated and still requires previously installed version 1.10 of virtualenv.
Now, reinstalling virtualenv like this
pdobrogost#host:~$ pip install --user --upgrade virtualenv
Downloading/unpacking virtualenv from https://pypi.python.org/packages/py27/v/virtualenv/virtualenv-1.11.1-py27-none-any.whl#md5=265770b61de41d34d2e9fdfddcdf034c
Using download cache from /home/users/pdobrogost/.pip_download_cache/https%3A%2F%2Fpypi.python.org%2Fpackages%2Fpy27%2Fv%2Fvirtualenv%2Fvirtualenv-1.11.1-py27-none-any.whl
Installing collected packages: virtualenv
Successfully installed virtualenv
Cleaning up...
does not help (neither pip install --user --upgrade --force-reinstall virtualenv) because script /home/users/pdobrogost/.local/bin/virtualenv is left unchanged.
The only way I could fix this was by manually removing virtualenv* scripts from /home/users/pdobrogost/.local/bin/ folder and installing virtualenv again. After this, newly generated scripts refer to the proper version of the package:
pdobrogost#host:~$ virtualenv --version
1.11
I was able to resolve this like so:
$ brew update
$ brew doctor
$ brew uninstall python
$ brew install python --build-from-source # took ~5 mins
$ python --version # => Python 2.7.9
$ pip install --upgrade pip
I'm running w/ the following stuff (as of Jan 2, 2015):
OS X Yosemite
Version 10.10.1
$ brew -v
Homebrew 0.9.5
$ python --version
Python 2.7.9
$ ipython --version
2.2.0
$ pip --version
pip 6.0.3 from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-6.0.3-py2.7.egg (python 2.7)
$ which pip
/usr/local/bin/pip
I was facing the similar problem in OSx. My stacktrace was saying
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: setuptools>=11.3
Then I did the following
sudo pip install --upgrade setuptools
This solved the problem for me. Hope someone will find this useful.
On Mac OS X (MBP), the following (taken from another answer found herein) resolved my issues:
C02L257NDV33:~ jjohnson$ brew install pip
Error: No available formula for pip
Homebrew provides pip via: `brew install python`. However you will then
have two Pythons installed on your Mac, so alternatively you can:
sudo easy_install pip
C02L257NDV33:~ jjohnson$ sudo easy_install pip
Clearly the root cause here is having a secondary method by which to install python (in my case Homebrew). Hopefully, the people responsible for the pip script can remedy this issue since its still relevant 2 years after first being reported on Stack Overflow.
I had this problem because I installed python/pip with a weird ~/.pydistutils.cfg that I didn't remember writing. Deleted it, reinstalled (with pybrew), and everything was fine.
In my case (sam problem, but other packages) there was no version dependency. A sequence of pip uninstall and pip insstall did help.