检测到python编程环境中存在多个版本_我的系统上的Python版本过多,导致出现问题...

这就是令我困惑的问题以及如何解决。

$ which python

/usr/bin/python

$ which python3

/usr/local/bin/python3

$ ls /usr/local/bin/python

ls: /usr/local/bin/python: No such file or directory

因此请注意,我没有安装python2.7的HomeBrew,但是安装了python3。/ usr / bin / python下的版本使用的是系统默认值。您可以根据模块搜索路径判断:

$ /usr/bin/python

Python 2.7.10 (default, Feb 7 2017, 00:08:15)

[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin

`enter code here`Type "help", "copyright", "credits" or "license" for

more information.

>>> import sys

>>> sys.path

['', '/Library/Python/2.7/...

请注意“ / Library / Python” ...,这是Mac OS的python版本。但是我想严格遵守用户安装的版本(即HomeBrew)。

因此,这是我为解决此问题所做的工作:

$ brew install python

...

Warning: python 2.7.13 is already installed, it's just not linked.

You can use `brew link python` to link this version.

$ brew link --overwrite python

$ which python

/usr/local/bin/python

$ python

Python 2.7.10 (default, Feb 7 2017, 00:08:15)

[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin

Type "help", "copyright", "credits" or "license" for more information.

>>> import sys

>>> sys.path

['', '/usr/local/Cellar/python/2.7.13...

它不再是/ Library / ..而是/ usr / local。

现在可以找到我所有的pip安装模块!问题解决了!

更新:

将brew更新到1.5.4版后,似乎删除了符号链接。现在,您必须将其添加到路径中:

export PATH="/usr/local/opt/python/libexec/bin:$PATH"

阅读“ brew info python”中的“警告”部分:

==> Caveats

This formula installs a python2 executable to /usr/local/bin.

If you wish to have this formula's python executable in your PATH then add

the following to ~/.bash_profile:

export PATH="/usr/local/opt/python/libexec/bin:$PATH"

Pip and setuptools have been installed. To update them

pip2 install --upgrade pip setuptools

You can install Python packages with

pip2 install

They will install into the site-package directory

/usr/local/lib/python2.7/site-packages

See: https://docs.brew.sh/Homebrew-and-Python.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值