简体   繁体   English

无法使用 'pyside-rcc' 编译 .qrc 文件

[英]Cannot use 'pyside-rcc' to compile .qrc file

I am working on python project and I have a problem with pyside-rcc.我正在研究 python 项目,但我遇到了 pyside-rcc 的问题。 First, let I explain briefly about my project.首先,让我简要介绍一下我的项目。

I created my project GUI in QtDesigner and also use the image in the GUI.我在 QtDesigner 中创建了我的项目 GUI,并在 GUI 中使用了图像。 Then, I generate .py from .ui file using pyside-uic and it works!然后,我使用 pyside-uic 从 .ui 文件生成 .py 并且它可以工作! Then I have to generate my resource file, .qrc file, to .py file to use with my project.然后我必须将我的资源文件 .qrc 文件生成为 .py 文件以用于我的项目。

The problem is when I use pyside-rcc to generate a resource file, it shows an error.问题是当我使用 pyside-rcc 生成资源文件时,它显示错误。

"'pyside-rcc' is not recognized as an internal or external command, operable probram or batch file." “'pyside-rcc' 不是内部或外部命令、可操作的程序或批处理文件。” (As shown below) (如下所示)

使用 pyside-rcc 时桌面图像显示错误

You can see in the bottom of Python folder.您可以在 Python 文件夹的底部看到。 There is pyside-rcc.exe file.有 pyside-rcc.exe 文件。 I do not know why pyside-rcc is not work (pyside-uic still work).我不知道为什么 pyside-rcc 不起作用(pyside-uic 仍然有效)。

Thank you for answer.谢谢你的答案。 :) :)

The pyside-uic tool is installed into a different folder than the other PySide tools (like pyside-rcc and pyside-lupdate ). pyside-uic工具安装在与其他PySide工具不同的文件夹中(如pyside-rccpyside-lupdate )。

To get all the tools working for Python-3.3, your PATH environment variable needs to include these two paths: 要使所有工具都适用于Python-3.3,您的PATH环境变量需要包含以下两个路径:

    C:\Python33\Lib\site-packages\PySide;C:\Python33\Scripts;

Once you've made the necessary changes, you will also need to re-open any command-prompt windows for the changes to take effect. 完成必要的更改后,还需要重新打开任何命令提示符窗口,以使更改生效。

This is more than likely a PATH problem, but what is odd is that pyside-uic works but pyside-rcc doesn't. 这很可能是一个PATH问题,但奇怪的是pyside-uic有效但pyside-rcc却没有。

Right click on My Computer and go to Properties. 右键单击“我的电脑”,然后转到“属性”。 Then click on Advanced System Settings. 然后单击“高级系统设置”。 Under the Advanced tab, click on the "Environment Variables..." button. 在“高级”选项卡下,单击“环境变量...”按钮。 A new window will open up and you will see a list showing "System variables". 将打开一个新窗口,您将看到一个显示“系统变量”的列表。 Scroll to the "Path" system variable, and either double click it or click the "Edit..." button. 滚动到“Path”系统变量,双击它或单击“编辑...”按钮。 At the beginning of the "Variable value:" entry, put in the directory to the folder that contains pyside-rcc.exe and put a semicolon (;) after it, like below: 在“变量值:”条目的开头,将目录放入包含pyside-rcc.exe的文件夹中,并在其后面加一个分号(;),如下所示:

C:\Path\To\PySideRCC\;C:\Paths\To\Other\Stuff1;C:\Paths\To\Other\Stuff2;C:\Paths\To\Other\Stuff3

Or put the directory at the end, but with the semicolon in front of it (after the last entry). 或者将目录放在最后,但在它前面加上分号(在最后一个条目之后)。 After doing this, you either have to logout and log back in or reboot in order for Windows to recognize the PATH changes. 执行此操作后,您必须注销并重新登录或重新启动才能让Windows识别PATH更改。 That should do the trick. 这应该够了吧。

或者你可以提到pyside-rcc.exe的完整路径,如:

C:/python/lib/../../pyside-rcc.exe -o input.qrc output.py

You need to set environment path for pyside-rcc to work.您需要为pyside-rcc设置环境路径才能工作。

First identify where is python.exe file is stored首先确定python.exe文件存储在哪里

Powershell电源外壳

PS C:> get-command python

Cmd命令

c:\> where python

Powershell get-command python output on my system我系统上的Powershell get-command python 输出

PS C:\> get-command python

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Application     python.exe                                         3.10.5150… C:\Users\user_name\AppData\Local\Programs\Python\Python310\python.exe

pyside6-rcc.exe and pyside6-uic.exe are present inside C:\Users\user_name\AppData\Local\Programs\Python\Python310\Scripts on my system pyside6-rcc.exepyside6-uic.exe存在于我系统上的C:\Users\user_name\AppData\Local\Programs\Python\Python310\Scripts

Add C:\Users\user_name\AppData\Local\Programs\Python\Python310\Scripts and C:\Users\user_name\AppData\Local\Programs\Python\Python310\Lib to the environment path and restart your terminal.C:\Users\user_name\AppData\Local\Programs\Python\Python310\ScriptsC:\Users\user_name\AppData\Local\Programs\Python\Python310\Lib添加到环境路径并重新启动终端。

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

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