-1

I had pip installed and installed few packages successfuly with it. However after running the following commands. I get an error saying no module named pip:

sudo chmod 666 /Library/Python/2.7/site-packages/
pip install --upgrade git+http://[email protected]/sympy/sympy.git
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 7, in <module>
    from pip import main
ImportError: No module named pip
4

2 Answers 2

3

Err... why did you run that chmod?

The issue here is that 666 is bad for directories. The permission bits, specifically the executable bit, has a different meaning for directories: in order to go into a directory, you need it to have the executable bit set. See, for example, this question or this one. Try running cd /Library/Python/2.7/site-packages/, and you'll see the problem.

So while you were trying to make the directory read-write for everyone, you actually made it so that no one can access it.

Running chmod +X /Library/Python/2.7/site-packages/ will fix this: the +X permission sets the executable bit only on directories (and files that already have +x).

Beyond this, however, do you really want something in /Library to be read-write for everyone? And have you considered (from the directory structure I'm assuming OS X) using something other than the Apple-provided Python, which often has problems with package installation, etc? I personally use the Homebrew version.

11
  • I run chmod +X /Library/Python/2.7/site-packages/ but the same error appears
    – MAS
    Apr 25, 2015 at 2:59
  • i was trying to install a python package without having to use sudo
    – MAS
    Apr 25, 2015 at 3:00
  • 1
    I'd strongly recommend using the homebrew version of Python then, which allows and is designed for that. Did you run just chmod, or chmod -R?
    – cge
    Apr 25, 2015 at 3:01
  • 1
    No you don't. virtualenv will install a separate isolated working pip environment.
    – b4hand
    Apr 25, 2015 at 3:23
  • 1
    Err... how did that happen? That's not 666 or 777. Try chmod +rwX /Library/Python/2.7/site-packages/
    – cge
    Apr 25, 2015 at 5:11
-1
sudo apt-get install --reinstall python-pkg-resources
2
  • 1
    Don't answer in one-liners without any explanation! See How to Answer!
    – jkalden
    Feb 20, 2017 at 9:36
  • Obviously you didn't read my link. Your answer lacks explanation and information and simply doesn't match the requirements for a good answer. You want to know why? See the link in my first comment. Take the tour! Read How to Ask and How to Answer. that's my recommendation...
    – jkalden
    Feb 27, 2017 at 8:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.