无法为Python 3安装Python虚拟环境

我正在关注
these instructions在我的运行Mac OSX High Sierra的MacBook上安装带有Homebrew的Python 3.

我在这一步遇到了麻烦:

Once you’ve installed Homebrew, insert the Homebrew directory at the top of your PATH environment variable. You can do this by adding the following line at the bottom of your ~/.profile file

export PATH=/usr/local/bin:/usr/local/sbin:$PATH

在更新〜/ .profile并运行python –version之后,我仍然看到Python 2.7.10.

这似乎是个问题,因为当我按照next page使用pip install –user pipenv安装虚拟环境时,安装完成后会收到以下警告:

The scripts pewtwo, pipenv and pipenv-resolver are installed in ‘/Users/charliesneath/Library/Python/2.7/bin’ which is not on PATH.

看起来我的系统没有正确地优先安装Homebrew的Python 3安装.

我怎样才能解决这个问题?

最佳答案 对于Mac,当您安装python3时,它将安装在与您引用的示例不同的路径中.要找出python3的安装位置,请键入命令行:

which python3

它将返回/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.

将以下行添加到.bash_profile:

PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
export PATH
点赞