我无法在MacOS Sierra上安装PIP

时间:2018-05-02 02:10:18

标签: python macos pip homebrew

我已经在Pycharm中运行Python 3一段时间了,我尝试安装新模块但无法安装。具体来说,它给了我一个“非零退出代码(1)”并告诉我尝试使用PIP从我的终端安装它。我已经更新并重新安装了Pycharm,它仍然不会安装新的模块。

在终端,我尝试了

pip --version

回应:

-bash: pip: command not found

我查找如何安装PIP,并尝试:

sudo easy_install pip

这就是它所说的:

Searching for pip
Reading https://pypi.python.org/simple/pip/
Download error on https://pypi.python.org/simple/pip/: [SSL:
TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol   version 
(_ssl.c:590) -- Some packages may not be found!
Couldn't find index page for 'pip' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/
Download error on https://pypi.python.org/simple/: [SSL:     
TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:590)
-- Some packages may not be found!
No local packages or download links found for pip
error: Could not find suitable distribution for     
Requirement.parse('pip')

所以我回到google并进行更多搜索并找到没有sudo的尝试,所以

easy_install pip

然后它给了我这个:

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/Python/2.7/site-packages/test-       
easy-install-2117.pth'

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

/Library/Python/2.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.

然后我找到了之前的问题:Why is Python easy_install not working on my Mac?

我试试:

sudo rm -f /usr/bin/easy_install*

它给了我

rm: /usr/bin/easy_install: Operation not permitted
rm: /usr/bin/easy_install-2.6: Operation not permitted
rm: /usr/bin/easy_install-2.7: Operation not permitted

然后我找到了这个老问题:Installing pip on macOS does not work (anymore),它有2个答案说要安装自制软件。所以我试试看:

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.comnn
/Homebrew/install/master/install)"

Homebrew安装,我想我已经准备好了。

pip --version

-bash: pip: command not found
编辑:我试过

echo $PATH

我忘记了我最初通过Anaconda使用Python并删除了它,这可能是从这开始的。有什么方法可以解决这个问题吗?

2 个答案:

答案 0 :(得分:3)

对于Mac OS Sierra,无法通过easy_install

安装pip

因此,请按如下所示使用curl安装pip,

curl https://bootstrap.pypa.io/get-pip.py | sudo python

答案 1 :(得分:0)

Pip已经与Python一起安装,因此如果它不起作用,则应尝试重新安装python(最新版本),然后尝试检查是否已安装pip。如果那不起作用-则应键入进入终端-卷曲https://bootstrap.pypa.io/get-pip.py |须藤python。 HTH(:。我尝试重新安装python,并且对我有用(我也在Mac电脑上)