PyQt5 pyuic 模块错误 [英] PyQt5 pyuic module error
问题描述
我正在尝试将一些 .ui 文件转换为 .py.我在互联网上寻找了一些教程,但似乎没有一个对我有用,在我的电脑上找不到 pyuic.bat,如果我运行
I'm tryng to convert some .ui file into .py. I looked all over the internet for some tutorials and none seem to work for me, pyuic.bat is not found anywere un mi pc, and if i run
python pyuic.py -o file.py file.ui
我总是遇到一些错误,例如:
i always get some errors like:
file "pyuic.py", line 28, in module
from .diver import Diver
Valuerror: Attempted relative import in non-package
我在 Windows 10 和 PyQt 5.6 上使用 python 2.7.
i'm using python 2.7 on windows 10, and PyQt 5.6.
推荐答案
根据您安装 PyQt5 的方式,您可能没有 pyuic5.bat
文件.但是你可以很容易地制作一个.只需创建一个名为 pyuic5.bat
的文件并将其放置在您的 PyQt5
目录中,例如C:\python-qt5\PyQt5
),并让文件包含:
You might not have the pyuic5.bat
file depending on how you installed PyQt5. But you can make one easily enough. Just create a file named pyuic5.bat
and place it in your PyQt5
directory e.g. C:\python-qt5\PyQt5
), and have the file contain:
python -m PyQt5.uic.pyuic %*
这要求:
- 您的
PyQt5
目录列在您的PYTHONPATH
中,例如C:\python-qt5
, - 包含
pyuic5.bat
的目录列在PATH
中,例如C:\python-qt5\PyQt5
.
- Your
PyQt5
directory is listed in yourPYTHONPATH
, e.g.C:\python-qt5
, - The directory containing
pyuic5.bat
is listed inPATH
, e.g.C:\python-qt5\PyQt5
.
这篇关于PyQt5 pyuic 模块错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!