C:/程序无法识别...与pyuic5相关 [英] C:/Program is not recognized ...related to pyuic5

查看:293
本文介绍了C:/程序无法识别...与pyuic5相关的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Windows 10 Pro上安装了Anaconda3-4.2.0.在安装过程中,我选择了Anaconda来设置Path变量.我使用QT设计器创建了一个小程序,并将其保存为hello.ui.我启动了Windows命令提示符,并将目录更改为保存hello.ui的目录.然后,在提示符下键入以下内容:

I installed Anaconda3-4.2.0 on Windows 10 Pro. During the installation I selected Anaconda to set the Path variable. I created a small program using QT designer and saved it as hello.ui. I launched Windows command prompt and changed directory to where hello.ui is saved. I then typed the following at the prompt:

C:\ Users \ HA \ Documents \ Python_Scripts \ GUI_Scripts> pyuic5 -x hello.ui -o hello.py

C:\Users\HA\Documents\Python_Scripts\GUI_Scripts> pyuic5 -x hello.ui -o hello.py

它给了我以下错误:

"C:/程序"未被识别为内部或外部命令,可操作程序或批处理文件.

'C:/Program' is not recognized as an internal or external command, operable program or batch file.

如何解决此问题?我的目标是从.ui文件创建一个.py文件.有没有其他我可以尝试的方法?

How can I resolve this issue? My goal is to create a .py file from the .ui file. Is there an alternative that I can try?

我尝试了以下操作:我在Google和stackoverflow上搜索了此错误( 'C:\ Program'无法识别错误),并且在path变量周围包含引号的建议对我不起作用.还有另一种建议重新安装Visual Studio 2015的Visual C ++ Redistributable(不知道为什么这样做会有所帮助,但尽管如此,我还是尝试过),但这也无济于事.

I have tried the following: I searched for this error on Google and on stackoverflow ('C:\Program' is not recognized error) and the suggestion to include quotes around the path variable didn't work for me. There was another suggestion to re-install Visual C++ Redistributable for Visual Studio 2015 (not sure why this would help, but nonetheless, I tried that), and that didn't help either.

以下是有关我的设置的一些相关信息. Anaconda3,pyuic5.bat和pyuic.py分别安装在以下目录中:

Below is some pertinent information about my settings. Anaconda3, pyuic5.bat, and pyuic.py are installed in the following directories (respectively):

C:\ Program文件

C:\Program Files

C:\ Program Files \ Anaconda3 \ Library \ bin

C:\Program Files\Anaconda3\Library\bin

C:\ Program Files \ Anaconda3 \ Lib \ site-packages \ PyQt5 \ uic

C:\Program Files\Anaconda3\Lib\site-packages\PyQt5\uic

系统变量下的Path变量包括与Anaconda3相关的以下项​​目:

The Path variable under System Variables include the following items related to Anaconda3:

C:\ Program Files \ Anaconda3; C:\ Program Files \ Anaconda3 \ Scripts; C:\ Program Files \ Anaconda3 \ Library \ bin

C:\Program Files\Anaconda3;C:\Program Files\Anaconda3\Scripts;C:\Program Files\Anaconda3\Library\bin

python.exe安装在C:\ Program Files \ Anaconda3中.但是,我可以运行以下程序而不会出现任何问题:

python.exe is installed in C:\Program Files\Anaconda3. However, I am able to run the following without any issues:

C:\ Users \ HA \ Documents \ Python_Scripts \ GUI_Scripts> python

C:\Users\HA\Documents\Python_Scripts\GUI_Scripts> python

'>>>

'>>>

我还能尝试什么?我还应该在这里包括哪些其他信息以帮助获得答案?

What else can I try? What other information should I include here to help with the answer?

我卸载了Anaconda3并重新安装了它,但是在重新安装过程中,我选择了C:\ Anaconda3作为安装目录.之后,我可以运行:

I uninstalled Anaconda3 and re-installed it, but during the re-installation, I chose C:\Anaconda3 as the installation directory. After that I was able to run:

pyuic5 -x hello.ui -o hello.py

pyuic5 -x hello.ui -o hello.py

成功生成了hello.py.这清楚地表明问题出在C:\ Program Files中.但是,为什么以前可以在任何目录中的Windows命令行中运行python.exe,而C:\ Program Files中的空间却不是问题呢?为什么只影响pyuic5?希望有人可以为可能会遇到此问题的其他人提供更多信息.大多数安装Anaconda3的人可能会选择程序文件"下的默认安装目录,他们将面临类似的问题.但是,对于那些根本不在乎哪个目录的人,我建议在某个明智的目录中安装Anaconda3,但要确保该目录的路径中没有空格.

which successfully produced hello.py. This clearly shows the problem was the space in C:\Program Files. However, why is it that earlier I could run python.exe from the Windows command line in any directory, and the space in C:\Program Files was not an issue there? Why it only affected pyuic5? Hopefully someone could shed more light on this for anyone else who might face this problem. Most people who install Anaconda3 might choose the default installation directory which is under Program Files and they will face a similar problem. However, for someone who simply doesn't care which directory, I would recommend installing Anaconda3 in some sensible directory but making sure that there is no space in the path to that directory.

推荐答案

问题出在 pyuic5 批处理文件中:

The problem lies in the pyuic5 batch file:

Windows首先调用批处理文件,在这种情况下,.bat中的 pyuic.py 脚本路径不包含引号. 如果路径不在引号中,Windows将停止在空白处阅读.

Windows calls the batch file first, and in this case, the path to the pyuic.py script within the .bat isn't surrounded by quotes. Windows stops reading at the space if the path isn't in quotes.

这就是为什么当您将Anaconda重新安装到没有空格的文件夹中时,问题消失了的原因.

That's why the problem disappeared when you re-installed Anaconda into a folder without spaces.

因此,请改成一个简单的解决方法!用记事本打开位于以下位置的 pyuic5.bat 文件:

So, a simple fix instead! Open up with notepad the pyuic5.bat file located at:

C:\ ... \ Anaconda3 \ Library \ bin \ pyuic5.bat

C:\...\Anaconda3\Library\bin\pyuic5.bat

并在路径两边加上引号:

And surround the path with quotes:

@"C:/.../Anaconda3 \ python.exe" -m PyQt5.uic.pyuic%1%2%3%4%5%6%7%8%9

@"C:/.../Anaconda3\python.exe" -m PyQt5.uic.pyuic %1 %2 %3 %4 %5 %6 %7 %8 %9

现在该命令将起作用:

pyuic5 -x hello.ui -o hello.py

pyuic5 -x hello.ui -o hello.py

这篇关于C:/程序无法识别...与pyuic5相关的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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