【问题标题】:Python modules work in imports but commands from modules not working in command linePython 模块在导入中起作用,但来自模块的命令在命令行中不起作用
【发布时间】:2017-04-25 15:50:43
【问题描述】:
我正在尝试在我的 Mac (El Capitan) 上构建一些 QGIS 插件并使用 Homebrew 安装 Python。我还安装了 SIP 和 PyQt4,并在/usr/local/lib/python2.7 下的站点包下查看它们。我可以在启动 Python 后导入 PyQt4。问题是当我运行命令pyrcc4 -o resources.py resources.qrc 时,我得到“-bash: pyrcc4: command not found”,我很确定 pyrcc4 是 PyQt4 附带的。
供参考:
-
which python 给我/usr/local/bin/python
-
python -V 给了我 Python 2.7.12
- 当我在终端中运行 python 然后导入 PyQt4 时,我没有收到任何错误。
我需要做什么才能让pyrcc4 命令工作?
我也试过brew install pyqt,但它一直说找不到公式。我需要使用 pyqt4 而不是 pyqt5。
【问题讨论】:
标签:
bash
python-2.7
pyqt
python-module
【解决方案1】:
pyrcc4 不存在此错误3rd 步骤将创建它
您需要按照以下步骤来解决此问题:
1. brew install cartr/qt4/qt@4
2. brew install cartr/qt4/qt-legacy-formula
3. brew install cartr/qt4/pyqt@4
4. pip install lxml
5. brew install libxml2
6. git clone https://github.com/tzutalin/labelImg.git
7. cd labelImg
8. make qt4py2
9. python labelImg.py
If PyQt4 is giving error after successful installation then use this
export PYTHONPATH=/usr/local/lib/python2.7/site-packages:$PYTHONPATH
对于所有其他不使用 Brew 的人,请关注此link
希望这能解决您的问题。如果没有,请告诉我。