问题
I'm trying to get started with the Ghost.py headless browser on a Mac. I installed Ghost.py and its dependencies using these links/commands:
- Qt 5.0.1 for Mac, has a GUI installer
- PySide 1.1.0, which requires
Qt Version >= 4.7.4
, has a GUI installer sudo pip install Ghost.py
I launched Python, and confirmed that I can import PySide
. However, when I do from ghost import Ghost
, it fails to find PySide:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ghost/__init__.py", line 1, in <module>
from ghost import Ghost
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/ghost/ghost.py", line 28, in <module>
raise Exception("Ghost.py requires PySide or PyQt")
Exception: Ghost.py requires PySide or PyQt
By doing import PySide; print PySide;
, it appears that PySide is installed here on my system: /Library/Python/2.7/site-packages/PySide
. So, appended the PYTHONPATH
like this: export PYTHONPATH=$PYTHONPATH:/Library/Python/2.7/site-packages #for PySide
.
However, Ghost.py
still cannot find PySide
.
How can I convince Ghost.py
to find my installation of PySide
?
Environment:
- Mac OS X 10.7.5
- Python 2.7
- Qt 5.0.1
- PySide 1.1.0
回答1:
I faced the exact same problem but managed to fix it. Here is how:
- Uninstall the current installation of PySide and qt on your system. Make sure PySide is not present in
/Library/Python/2.7/site-packages
. - Install qt and PySide from http://qt-project.org/wiki/PySide_Binaries_MacOSX.
PS: My system is running 10.9 (Mavericks) but I think it should work in 10.7 (Mountain Lion) as well.
来源:https://stackoverflow.com/questions/15047426/ghost-py-not-finding-pyside