簡體   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