我通过brew
安装了pip,我无法使用python 3而不是2.7。以下是我认为可能与展示正在发生的事情相关的信息。
$ pip -V
pip 9.0.1 from /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7)
$ pip2 -V
pip 9.0.1 from /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg (python 2.7)
$ pip3 -V
-bash: pip3: command not found
$ which pip
/usr/local/bin/pip
$ sudo python3 get-pip.py
The directory '/Users/tj/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/tj/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already up-to-date: pip in /usr/local/Cellar/python3/3.6.4_2/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
$ sudo easy_install3 pip
sudo: easy_install3: command not found
$ sudo easy_install-3.6 pip
sudo: easy_install-3.6: command not found
$ sudo easy_install pip
Searching for pip
Best match: pip 9.0.1
Processing pip-9.0.1-py2.7.egg
pip 9.0.1 is already the active version in easy-install.pth
Installing pip script to /usr/local/bin
Installing pip2.7 script to /usr/local/bin
Installing pip2 script to /usr/local/bin
Using /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg
Processing dependencies for pip
Finished processing dependencies for pip
我尝试了一切我在网上找不到运气的东西。这个问题的主要症状是当我使用pip来安装软件包时,它总是进入2.7(或者因为numpy被弃用或者类似的东西而无法安装)。
答案 0 :(得分:3)
在OSX上,brew(或其他)python 2.7 / 3单独安装到OSX附带的旧版本2.7。相信我,当我说你不想与它交往时。
尝试输入pip3
$ pip3 --version
$ pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)
而pip(for 2.7)甚至没有安装。
$ pip --version
$ zsh: command not found: pip
即使您尝试:
$ brew install pip
导致
If you meant "pip" specifically:
Homebrew provides pip via: `brew install python`. However you will then
have two Pythons installed on your Mac, so alternatively you can install
pip via the instructions at:
https://pip.readthedocs.io/en/stable/installing/
作为最后的度假村:
python3 -m ensurepip
将确保/修复系统有它。
pip3应位于/usr/local/bin/pip3
内容是:
#!/usr/local/opt/python3/bin/python3.6
# EASY-INSTALL-ENTRY-SCRIPT: 'pip==9.0.1','console_scripts','pip3'
__requires__ = 'pip==9.0.1'
import re
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(
load_entry_point('pip==9.0.1', 'console_scripts', 'pip3')()
)