简体   繁体   English

使用Homebrew安装的模块的Python导入错误

[英]Python Import Error for modules installed with Homebrew

I've already installed PySide using homebrew, but I get an error when my scripts run things such as 我已经使用自制软件安装了PySide,但是当我的脚本运行诸如

from PySide import QtWebKit

When I try brew install pyside I get an error that pyside-1.2.0 already installed 当我尝试brew install pyside我得到一个错误,即pyside-1.2.0 already installed

When I try pip install pyside I get the following error: 当我尝试pip install pyside ,出现以下错误:

In file included from /Users/fitvalet/wgwt/env/build/pyside/sources/pyside/plugins/customwidgets.cpp:23:

/Users/fitvalet/wgwt/env/build/pyside/sources/pyside/plugins/customwidget.h:27:10: fatal error: 'QtDesigner/QtDesigner' file not found

fatal error: 'QtDesigner/QtDesigner' file not found

#include <QtDesigner/QtDesigner>

     ^

2 warnings and 1 error generated.

make[2]: *** [plugins/CMakeFiles/uiplugin.dir/customwidgets.cpp.o] Error 1

make[1]: *** [plugins/CMakeFiles/uiplugin.dir/all] Error 2

make: *** [all] Error 2

error: Error compiling pyside

...

Command /Users/fitvalet/WGWT/env/bin/python -c 
"import setuptools;__file__='/Users/fitvalet/WGWT/env/build/pyside/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" 
install --record /var/folders/rb/qjx8psqs3gj48qmpgbqqvrhc0000gn/T/pip-h69ltB-record/install-record.txt --single-version-externally-managed --install-headers 
/Users/fitvalet/WGWT/env/include/site/python2.7 failed with error code 1 in 
/Users/fitvalet/WGWT/env/build/pyside
Storing complete log in /Users/fitvalet/.pip/pip.log

I also tried easy_install pyside and got this error: 我也尝试了easy_install pyside并得到了这个错误:

2 warnings and 1 error generated.
make[2]: *** [plugins/CMakeFiles/uiplugin.dir/customwidgets.cpp.o] Error 1
make[1]: *** [plugins/CMakeFiles/uiplugin.dir/all] Error 2
make: *** [all] Error 2
error: Setup script exited with error: Error compiling pyside

I figured out the problem by reinstalling the homebrew installation of PySide. 我通过重新安装PySide的自制软件解决了这个问题。

When you install using homebrew, you get a warning that 当您使用自制软件安装时,会收到警告

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

Ran this and the module worked. 跑这个,模块工作。

To make the change automatic rather than having to type the line each time I opened a new terminal console, I needed to add that line to my ./bash_profile file. 为了使更改自动进行,而不必每次我打开新的终端控制台时都键入该行,我需要将该行添加到我的./bash_profile文件中。

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

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