0

I got the below issue when trying to setup virtualenvwrapper on a new laptop(worked ok on a previous one).

Last login: Tue Aug 18 17:03:39 on ttys001
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/Library/Python/2.7/site-packages/virtualenvwrapper/hook_loader.py", line 16, in <module>
    from stevedore import ExtensionManager
  File "/Library/Python/2.7/site-packages/stevedore/__init__.py", line 11, in <module>
    from .extension import ExtensionManager
  File "/Library/Python/2.7/site-packages/stevedore/extension.py", line 4, in <module>
    import pkg_resources
ImportError: No module named pkg_resources
virtualenvwrapper.sh: There was a problem running the initialization hooks.

Not sure whey there are no pkg_resources but I tried to solve by installing with:

sudo curl https://bootstrap.pypa.io/ez_setup.py -o - | python

which gave me this error:

Installing Setuptools
running install
error: can't create or remove files in install directory

The following error occurred while trying to add or remove files in the
installation directory:

    [Errno 13] Permission denied: '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/test-easy-install-3286.write-test'

The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:

    /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/

Perhaps your account does not have write access to this directory?  If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account.  If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.

For information on other options, you may wish to consult the
documentation at:

  https://pythonhosted.org/setuptools/easy_install.html

Please make the appropriate changes for your system and try again.

Something went wrong during the installation.

Any ideas why it couldn't install when I used sudo? Thanks

Yunti
  • 4,812
  • 9
  • 42
  • 85
  • possible duplicate of [No module named pkg\_resources](http://stackoverflow.com/questions/7446187/no-module-named-pkg-resources) – ganduG Aug 21 '15 at 18:00
  • 1
    Only the `curl` gets run as `sudo` not `python`. The command should be: `curl https://bootstrap.pypa.io/ez_setup.py -o - | sudo python` – ganduG Aug 21 '15 at 18:01
  • 1
    Thanks the command you mentioned solved it perfectly. Just to confirm my understanding do you mean only python gets runs with sudo hence: sudo python at the end? – Yunti Aug 21 '15 at 18:15
  • When you pipe multiple commands the `sudo` becomes a part of the first command and subsequent commands don't run as root. So in your case the `curl` call was being run as root, but the `python` invocation wasn't. – ganduG Aug 21 '15 at 20:58

0 Answers0