Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attribute Error Installing with pip

Tags:

python

macos

pip

This is a head stumper so I am posting this question AFTER having examined and read all of the prior posts on this issue.

Running OSX 10.9 Python 2.7 no virtualenv

pip install awssh

Downloading/unpacking awssh

  Downloading awssh-0.1.tar.gz
Cleaning up...

Exception:
Traceback (most recent call last):
  File "/Library/Python/2.7/site-packages/pip-1.5.2-py2.7.egg/pip/basecommand.py", 

line 122, in main
    status = self.run(options, args)
  File "/Library/Python/2.7/site-packages/pip-1.5.2-py2.7.egg/pip/commands/install.py", 

line 274, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/Library/Python/2.7/site-packages/pip-1.5.2-py2.7.egg/pip/req.py", 

line 1215, in prepare_files
    req_to_install.run_egg_info()
  File "/Library/Python/2.7/site-packages/pip-1.5.2-py2.7.egg/pip/req.py", 

line 288, in run_egg_info
    logger.notify('Running setup.py (path:%s) egg_info for package %s' % (self.setup_py, self.name))
  File "/Library/Python/2.7/site-packages/pip-1.5.2-py2.7.egg/pip/req.py", 

line 265, in setup_py
    import setuptools
  File "/Library/Python/2.7/site-packages/setuptools/__init__.py", line 11, in <module>

    from setuptools.extension import Extension
  File "/Library/Python/2.7/site-packages/setuptools/extension.py", line 8, in <module>

 File "/Library/Python/2.7/site-packages/setuptools/dist.py", line 21, in <module>
    packaging = pkg_resources.packaging

AttributeError: 'module' object has no attribute 'packaging'
like image 414
user2016754 Avatar asked Mar 10 '15 15:03

user2016754


1 Answers

This error is caused by the presence of an outdated version of pkg_resources. In order to get rid of the error, do the following:

  1. Start a python session, import pkg_resources, and view the file from which it is loaded:

    In [1]: import pkg_resources
    
    In [2]: pkg_resources.__file__
    Out[2]: '/usr/lib/python2.7/dist-packages/pkg_resources.pyc'
    
  2. Remove this file (and the associated *.py file):

    $ sudo rm /usr/lib/python2.7/dist-packages/pkg_resources.py*
    
  3. That's it! Re-run the installation; it should complete without any errors:

    $ sudo pip install awssh
    

Warning

If you're on a Debian based Linux system, this file might have been installed via the python-pkg-resources package. Therefore updating or reinstalling this package will reinstate the stale module! Also be aware that you're messing with a file which is supposed to be controlled by apt.

like image 65
dbliss Avatar answered Oct 24 '22 00:10

dbliss