pip installation /usr/local/opt/python/bin/python2

2019-01-10 03:22发布

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

15条回答
欢心
2楼-- · 2019-01-10 03:56

I got same problem. If I run brew link --overwrite python2. There was still zsh: /usr/local/bin//fab: bad interpreter: /usr/local/opt/python/bin/python2.7: no such file or directory.

cd /usr/local/opt/
mv python2 python

Solved it! Now we can use python2 version fabric.

=== 2018/07/25 updated

There is convinient way to use python2 version fab when your os python linked to python3. .sh for your command.

# fab python2
cd /usr/local/opt
rm python
ln -s python2 python

# use the fab cli
...

# link to python3
cd /usr/local/opt
rm python
ln -s python3 python

Hope this helps.

查看更多
狗以群分
3楼-- · 2019-01-10 03:58
sudo /usr/bin/easy_install pip

this command worked out for me

查看更多
看我几分像从前
4楼-- · 2019-01-10 03:59

In my case, I decided to remove the homebrew python installation from my mac as I already had two other versions of python installed on my mac through MacPorts. This caused the error message.

Reinstalling python through brew solved my issue.

查看更多
小情绪 Triste *
5楼-- · 2019-01-10 03:59

Because I had both python 2 and 3 installed on Mac OSX I was having all sorts of errors.

I used which to find the location of my python2.7 file (/usr/local/bin/python2.7)

which python2.7

Then I symlinked my real python2.7 install location with the one the script expected:

ln -s /usr/local/bin/python2.7 /usr/local/opt/python/bin/python2.7
查看更多
够拽才男人
6楼-- · 2019-01-10 03:59

Yes. it seems it is a quite frequent problem. One solution is install Anaconda3, download Anaconda3-4.2.0-Linux-x86_64.sh and Anaconda3 will provide you python and pip at the same time and they are coordinated.

查看更多
冷血范
7楼-- · 2019-01-10 04:01

I made the same error using sudo for my installation. (oops)

brew install python
brew linkapps python
brew link --overwrite python 

This brought everything back to normal.

查看更多
登录 后发表回答