PyQt5 pyuic 模块错误 [英] PyQt5 pyuic module error

查看:121
本文介绍了PyQt5 pyuic 模块错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一些 .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 your PYTHONPATH, e.g. C:\python-qt5,
  • The directory containing pyuic5.bat is listed in PATH, e.g. C:\python-qt5\PyQt5.

这篇关于PyQt5 pyuic 模块错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆