简体   繁体   English

系统默认python不能使用自制软件安装包

[英]system default python can't use homebrew installed package

I have different versions of python installed on my mac.我的 mac 上安装了不同版本的 python。 My system default python is ( $ which python ) "/Library/Frameworks/Python.framework/Versions/2.7/bin/python" .我的系统默认 python 是 ( $ which python ) "/Library/Frameworks/Python.framework/Versions/2.7/bin/python"

And if I install something with pip command such as pip install numpy , the package will be installed in the system python's site-package "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages"如果我使用pip命令安装某些东西,例如pip install numpy ,该包将安装在系统 python 的站点包"/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages"

However, I want to setup ipython & Qt working environment.但是,我想设置 ipython & Qt 工作环境。 So I brew install pyqt , brew install PySide And these packages are installed in my home-brew python pack-control part.所以我brew install pyqt , brew install PySide并且这些包安装在我的 home-brew python pack-control 部分。 My home-brew python is in "/usr/local/lib/python2.7/site-packages" .我的自制 python 在"/usr/local/lib/python2.7/site-packages"

Now my python just can't import any Qt or PySide ... Any suggestions?现在我的 python 无法导入任何QtPySide ......有什么建议吗? How can I fix this?我怎样才能解决这个问题?

Use the /usr/local/bin/python instead of the system installed python.使用 /usr/local/bin/python 而不是系统安装的 python。

brew doctor should tell you that /usr/local/bin is not early enough in your path. brew doctor应该告诉您 /usr/local/bin 在您的路径中还不够早。 By putting /usr/local/bin first (or earlier than /usr/bin) in your path, your shell will find homebrew versions of executables before system versions.通过将 /usr/local/bin 首先(或早于 /usr/bin)放在您的路径中,您的 shell 将在系统版本之前找到可执行文件的自制版本。

If you don't want to adjust your path, you can invoke which python you want to run.如果不想调整路径,可以调用要运行的python。 /usr/local/bin/python instead of just python at the shell prompt. /usr/local/bin/python而不仅仅是 shell 提示符下的python

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM