# pip --version
pip 6.1.1 from /usr/local/lib/python2.7/dist-packages (python 2.7)
# pip install supervisor --pre
Collecting supervisor
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:79: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Downloading supervisor-3.1.3.tar.gz (391kB)
100% |鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 393kB 950kB/s
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 246, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/dist-packages/pip/commands/install.py", line 342, in run
requirement_set.prepare_files(finder)
File "/usr/local/lib/python2.7/dist-packages/pip/req/req_set.py", line 345, in prepare_files
functools.partial(self._prepare_file, finder))
File "/usr/local/lib/python2.7/dist-packages/pip/req/req_set.py", line 290, in _walk_req_to_install
more_reqs = handler(req_to_install)
File "/usr/local/lib/python2.7/dist-packages/pip/req/req_set.py", line 502, in _prepare_file
abstract_dist.prep_for_dist()
File "/usr/local/lib/python2.7/dist-packages/pip/req/req_set.py", line 123, in prep_for_dist
self.req_to_install.run_egg_info()
File "/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py", line 363, in run_egg_info
self.setup_py, self.name,
File "/usr/local/lib/python2.7/dist-packages/pip/req/req_install.py", line 334, in setup_py
import setuptools # noqa
File "/usr/local/lib/python2.7/dist-packages/setuptools/__init__.py", line 11, in <module>
from setuptools.extension import Extension
File "/usr/local/lib/python2.7/dist-packages/setuptools/extension.py", line 8, in <module>
from .dist import _get_unpatched
File "/usr/local/lib/python2.7/dist-packages/setuptools/dist.py", line 21, in <module>
packaging = pkg_resources.packaging
AttributeError: 'module' object has no attribute 'packaging'
I think this might be because of the patching that Debian does, maye @warsaw can give some insight?
I could have a look - what OS is this on, and what version of python-pkg-resources do you have installed?
I see you've installed a local setuptools - what version is that ('pip list' should show it).
I was facing a similar problem. It appeared to be because of a stale compiled file (pkg_resources.pyc).
I did
import pkg_resources
print pkg_resources.__file__
I deleted the compiled file and everything was fine.
I got this error and tried un- and reinstalling pip. To my surprise... pip wasn't installed.
sudo apt-get install python-pip
I felt so stupid I almost couldn't post this. Hope it helps anyone as dim as me!
"I deleted the compiled file and everything was fine."
Had the same issue in a completely different package on Ubuntu and deleting the .pyc files also did the trick. Google brought me here.
I also stumbled across this thread from Google and I solved it by running:
sudo pip install PACKAGENAME
My target directory requires elevated user rights to install python packages there, which I knew, but I usually got a different (permission) error, when running pip
without sudo
, so I thought it was still worth sharing.
geremih commented on May 4
print pkg_resources.file
I deleted the compiled file and everything was fine.
Thanks, this just worked for me as well. Actually that file was from an old distribute installation, which I removed by
$ pip uninstall distribute
Uninstalling distribute-0.6.49:
/opt/dynasdk/loco2-rhel6/bin/easy_install
/opt/dynasdk/loco2-rhel6/bin/easy_install-2.7
/opt/dynasdk/loco2-rhel6/lib/python2.7/site-packages/distribute-0.6.49-py2.7.egg
Proceed (y/n)? y
Successfully uninstalled distribute-0.6.49
I wonder if pip could detect this case.
Note that on a Debian or Ubuntu system (e.g. Ubuntu 14.04 LTS, which comes with setuptools 3.3) you're messing with files supposedly controlled by apt
when removing the stale pkg_resources
module. This means if the python-pkg-resources
package is ever upgraded or reinstalled, the stale module is reinstated!
This issue is discussed in more detail on Stack Overflow and ask ubuntu.
@DSLituiev thats a problem with easy-install, nothing to do with pip, sorry, even though the error is similar.
my own experience, i had both local installation of setuptools and the deb from ubuntu. not sure how that got there. i ended up removing the local install and all was well:
the error message:
$ sudo pip install gsync
Downloading/unpacking gsync
Downloading gsync-0.1.14.tar.gz (44kB): 44kB downloaded
Cleaning up...
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 304, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1230, in prepare_files
req_to_install.run_egg_info()
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 293, in run_egg_info
logger.notify('Running setup.py (path:%s) egg_info for package %s' % (self.setup_py, self.name))
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 266, in setup_py
import setuptools
File "/usr/lib/python2.7/dist-packages/setuptools/init.py", line 11, in
from setuptools.extension import Extension
File "/usr/lib/python2.7/dist-packages/setuptools/extension.py", line 8, in
from .dist import _get_unpatched
File "/usr/lib/python2.7/dist-packages/setuptools/dist.py", line 21, in
packaging = pkg_resources.packaging
AttributeError: 'module' object has no attribute 'packaging'
troubleshooting:
$ dpkg -l _setuptools_
ii python-setuptools 12.2-1 all Python Distutils Enhancements
un python2.7-setuptools
un python3-setuptools
un python3.4-setuptools
$ locate pkg_resources.pyc
/usr/lib/python2.7/dist-packages/pkg_resources/tests/test_pkg_resources.pyc
/usr/local/lib/python2.7/dist-packages/pip-6.1.1-py2.7.egg/pip/_vendor/pkg_resources/tests/test_pkg_resources.pyc
$ ipython
In [1]: import pkg_resources
In [2]: print pkg_resources.file
/usr/local/lib/python2.7/dist-packages/setuptools-6.0.1-py2.7.egg/pkg_resources.pyc
fix:
$ sudo mv /usr/local/lib/python2.7/dist-packages/setuptools-6.0.1-py2.7.egg ~/
$ sudo pip install gsync
Downloading/unpacking gsync
Downloading gsync-0.1.14.tar.gz (44kB): 44kB downloaded
Running setup.py (path:/tmp/pip-build-FUAtVy/gsync/setup.py) egg_info for package gsync
...
I had the same issue. After upgrading "distribute" from 0.6.24 to 0.7.3, it works. (pip install --upgrade distribute)
@hectord note that distribute is deprecated and abandoned after the project was merged back into setuptools
It looks like an issue with a debundled version of pip combined with an upgrade of setuptools.
Nothing much pip could do.
Most helpful comment
I had the same issue. After upgrading "distribute" from 0.6.24 to 0.7.3, it works. (pip install --upgrade distribute)