【发布时间】:2018-04-10 20:07:46
【问题描述】:
我正在尝试将我的 .ui 文件转换为 .py 文件。我正在使用 PyQt5 和 Python 3.6。
当尝试以下命令时,它们都失败了:
C:\Python35\Lib\site-packages\PyQt5>pyuic5 FirstApp.ui -o FirstApp.py
'"C:\Python35\python"' is not recognized as an internal or external command,
operable program or batch file.
C:\Python35\Lib\site-packages\PyQt5>pyuic5.bat -x FirstApp.ui -o FirstApp.py
'"C:\Python35\python"' is not recognized as an internal or external command,
operable program or batch file.
C:\Python35\Lib\site-packages\PyQt5>pyuic4 -x FirstApp.ui -o FirstApp.py
'pyuic4' is not recognized as an internal or external command,
operable program or batch file.
C:\Python35\Lib\site-packages\PyQt5>pyuic4 FirstApp.ui -o FirstApp.py
'pyuic4' is not recognized as an internal or external command,
operable program or batch file.
我确保FirstApp.ui 文件与pyuic.bat 文件位于同一位置,并且还在系统设置中添加了指向我的环境变量的路径。我什至重新安装了 PyQt5。
我还尝试通过编辑位于C:\Python35\Lib\Site-Packages\PyQt5 中的pyuic5.bat 文件来解决此问题,如下所示:
原文:
@"C:\Python35\python" -m PyQt5.uic.pyuic %1 %2 %3 %4 %5 %6 %7 %8 %9
我的编辑:将我的 bat 文件指向我的 Python 目录所在的位置:
@"C:\Program Files\Python36\python.exe" -m PyQt5.uic.pyuic %1 %2 %3 %4 %5 %6 %7 %8 %9
然后当我再次尝试运行转换命令时,我得到一个新错误:
C:\Program Files\Python36\python.exe: Error while finding module specification for 'PyQt5.uic.pyuic' (ModuleNotFoundError: No module named 'PyQt5')
我不确定接下来要做什么来解决这个非常令人沮丧的错误。我该如何解决这个问题?
【问题讨论】:
-
试试看:C:\Python35\Scripts\pyuic5.exe FirstApp.ui -o FirstApp.py
-
嗨,S.Nick。我的 Python 目录没有 Scripts 文件夹。
标签: python python-3.x pyqt5