简体   繁体   English

用brew安装Pyqt4

[英]Installing Pyqt4 with brew

Im working with brew to install PyQt on python3 but I cant seem to get it to work 我正在使用brew在python3上安装PyQt,但我似乎无法让它工作

I ran brew install pyqt and brew doctor to fix all possible errors but still when running my code I keep getting 我运行brew install pyqtbrew doctor来修复所有可能的错误,但仍然在运行我的代码时我一直在努力

ImportError: No module named 'PyQt4'

If I run echo $PATH im getting /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin 如果我运行echo $PATH获取/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin

Can someone please guide me on fixing this problem? 有人可以指导我解决这个问题吗? I am also using PyCharm but I still get the same error if I run in terminal python3 then import pyqt 我也在使用PyCharm,但如果我在终端python3运行然后import pyqt我仍会得到相同的错误

please help me :( im really new in this but I tried everything that I could find in google 请帮助我:(我真的很新,但我尝试了一切,我可以在谷歌找到

thanks! 谢谢!

PD: Running brew test pyqt does not bring an error but it does not open. PD:运行brew test pyqt不会带来错误,但它不会打开。 Also I installed python3 with brew and im currently running it from /usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/bin/python3.4 我还安装了python3和brew,我目前正在运行它来自/usr/local/Cellar/python3/3.4.3/Frameworks/Python.framework/Versions/3.4/bin/python3.4

如果你想在Python 3中使用PyQt4,你应该使用这个命令告诉自制软件:

brew install PyQt --with-python3

I had the exact same problem. 我有同样的问题。 Installing using the instructions of Longhanks did not work as it said it was already installed. 使用Longhanks的说明安装不起作用,因为它说它已经安装。 I got it working with 我得到了它

brew reinstall PyQt --with-python3

The following method is for python 2.7. 以下方法适用于python 2.7。 You can replace the 2.7 into your current python version like 3.4 (enter the directory to see which to use). 您可以将2.7替换为当前的python版本,如3.4(输入目录以查看要使用的目录)。

Because by default the python package is installed in /usr/local/lib/python2.7/site-packages which is not included in python library 因为默认情况下python包安装在/usr/local/lib/python2.7/site-packages ,而不包含在python库中
try: 尝试:

mkdir -p /Users/zgf/Library/Python/2.7/lib/python/site-packages
echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> /Users/zgf/Library/Python/2.7/lib/python/site-packages/homebrew.pth

where zgf should be replaced by your username in OSX. 其中zgf应该用OSX中的用户名替换。

You can also copy the relevant files from /usr/local/lib/python2.7/site-packages into your personal python site package directory or public site package directory (/Library/Python/2.7/site-packages) if you can root. 如果你能root,你也可以将/usr/local/lib/python2.7/site-packages的相关文件复制到个人python站点包目录或公共站点包目录(/Library/Python/2.7/site-packages)中。 。

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

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