HomeBrew Mac change Python Path

南笙酒味 提交于 2019-12-21 09:26:37

问题


I am trying to install PyQT and I used PyQT. Is has been installed using home brew. But When I try to import it, python can't. I get the following warning in Home brew. I am new to Mac and can't figure out how to change the python path. Any help would be great.

For non-homebrew python (2.x), you need to amend your PYTHONPATH like so: export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH


回答1:


You should edit ~/.bash_profile (create the file if it does not exist) to set the PYTHONPATH environment variable:

export PYTHONPATH=`brew --prefix`/lib/python2.7/site-packages:$PYTHONPATH



回答2:


Since you installed PyQt by using Homebrew, you should also use Homebrew Python 2.

To install it, run: brew install python

Now, you can import PyQt normally.



来源:https://stackoverflow.com/questions/17033096/homebrew-mac-change-python-path

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!