问题描述
我已经在Pycharm中运行Python 3一段时间了,我试图安装一个新模块,但安装失败.具体来说,它给了我一个非零退出代码(1)",并告诉我尝试使用PIP从我的终端安装它.此后,我更新并重新安装了Pycharm,但它仍然不会安装新模块.
I've been running Python 3 in Pycharm for a while now, and I tried to install a new module and it failed to install. Specifically it gave me a "Non-zero exit code (1)" and told me to attempt to install it from my terminal using PIP. I have since updated and reinstalled Pycharm and it still will not install new modules.
在终端机中,我尝试过
pip --version
响应:
-bash: pip: command not found
我查看了如何安装PIP,然后尝试:
I look up how to install PIP, and try:
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可以尝试使用它,所以
So I go back to google and do a little more searching and find to try it without the sudo, so
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上无法使用吗?
so then I find this earlier question: 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
因此,我发现了这个老问题:在macOS上安装pip确实可以(不再),它有2条回答说只能安装自制软件.所以我尝试:
So then I find this old question: Installing pip on macOS does not work (anymore), which has 2 answers saying to just install homebrew. So I try that:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.comnn
/Homebrew/install/master/install)"
自制软件安装完毕,我想我已经准备好了.
Homebrew installs, and I think I'm ready to go.
pip --version
-bash: pip: command not found
我尝试过
echo $PATH
我忘记了我最初是通过Anaconda使用Python并将其删除的,而这可能正是由此开始的.有什么办法可以解决这个问题?
I had forgotten that I originally used Python through Anaconda and removed it, and that's probably what started this. Is there any way to fix this?
推荐答案
对于Mac OS Sierra,无法通过 easy_install
For Mac OS Sierra, cannot install pip via easy_install
因此,请按如下所示使用curl安装pip,
So install pip using curl as follows,
curl https://bootstrap.pypa.io/get-pip.py | sudo python
这篇关于我无法在MacOS Sierra上安装PIP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!