Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pip installation /usr/local/opt/python/bin/python2.7: bad interpreter: No such file or directory

I don't know what's the deal but I am stuck following some stackoverflow solutions which gets nowhere. Can you please help me on this?

  Monas-MacBook-Pro:CS764 mona$ sudo python get-pip.py     The directory '/Users/mona/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.     The directory '/Users/mona/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.     /tmp/tmpbSjX8k/pip.zip/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: 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.     Collecting pip       Downloading pip-7.1.0-py2.py3-none-any.whl (1.1MB)         100% |████████████████████████████████| 1.1MB 181kB/s      Installing collected packages: pip       Found existing installation: pip 1.4.1         Uninstalling pip-1.4.1:           Successfully uninstalled pip-1.4.1     Successfully installed pip-7.1.0     Monas-MacBook-Pro:CS764 mona$ pip --version     -bash: /usr/local/bin/pip: /usr/local/opt/python/bin/python2.7: bad interpreter: No such file or directory 
like image 491
Mona Jalal Avatar asked Aug 02 '15 02:08

Mona Jalal


People also ask

How do I download Pip on my Mac?

To use the get-pip script to install PIP on Mac:Open the Terminal app via the Launchpad. In the Terminal, type curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py and press Enter. Allow curl time to download the script onto your Mac. Once it's done, type python3 get-pip.py and press Enter.


2 Answers

I had used home-brew to install 2.7 on OS X 10.10 and the new install was missing the sym links. I ran

brew link --overwrite python 

as mentioned in How to symlink python in Homebrew? and it solved the problem.

like image 97
LancDec Avatar answered Oct 04 '22 18:10

LancDec


I'm guessing you have two python installs, or two pip installs, one of which has been partially removed.

Why do you use sudo? Ideally you should be able to install and run everything from your user account instead of using root. If you mix root and your local account together you are more likely to run into permissions issues (e.g. see the warning it gives about "parent directory is not owned by the current user").

What do you get if you run this?

$ head -n1 /usr/local/bin/pip 

This will show you which python binary pip is trying to use. If it's pointing /usr/local/opt/python/bin/python2.7, then try running this:

$ ls -al /usr/local/opt/python/bin/python2.7 

If this says "No such file or directory", then pip is trying to use a python binary that has been removed.

Next, try this:

$ which python $ which python2.7 

To see the path of the python binary that's actually working.

Since it looks like pip was successfully installed somewhere, it could be that /usr/local/bin/pip is part of an older installation of pip that's higher up on the PATH. To test that, you may try moving the non-functioning pip binary out of the way like this (might require sudo):

$ mv /usr/local/bin/pip /usr/local/bin/pip.old 

Then try running your pip --version command again. Hopefully it picks up the correct version and runs successfully.

like image 24
Steven Kryskalla Avatar answered Oct 04 '22 17:10

Steven Kryskalla