繁体   English   中英

我无法在 MacOS Sierra 上安装 PIP

[英]I can't install PIP on MacOS Sierra

我已经在 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')

所以我回到谷歌并进行更多搜索并找到在没有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.

所以我发现了这个较早的问题: 为什么 Python easy_install 不能在我的 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

然后我发现了这个老问题: 在 macOS 上安装 pip 不起作用(不再) ,其中有 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 并将其删除,这可能是开始的原因。 有没有什么办法解决这一问题?

对于 Mac OS Sierra,无法通过easy_install安装 pip

所以使用 curl 安装 pip 如下,

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

Pip 已经与 Python 一起安装,所以如果它不工作,那么你应该尝试重新安装 python(最新版本),然后尝试检查你是否安装了 pip。如果这不起作用 - 那么你应该在终端中输入- curl https://bootstrap.pypa.io/get-pip.py | 须藤蟒蛇。 HTH(:。我尝试重新安装python,这对我有用(我也在Mac上)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM