简体   繁体   English

py2exe cmd失败

[英]py2exe cmd failure

i wrote a python script and installed py2exe 0.6.9 (win32) to a 32bit-Windows7 machine with Python 2.7. 我编写了一个python脚本,并将py2exe 0.6.9(win32)安装到具有python 2.7的32位Windows7计算机上。 I could successfully run "python setup.py py2exe" via cmd. 我可以通过cmd成功运行“ python setup.py py2exe”。 Now I installed py2exe 0.6.9 (win64) to a 2nd PC (Win7, 64bit, Python2.7) and tried the same to exactly the same script: But "python setup.py py2exe" returned this message (hope I translated it correctly into english): "The command 'python' is either written wrong or couldn't be found." 现在,我将py2exe 0.6.9(win64)安装到第二台PC(Win7、64位,Python2.7),并尝试将其完全相同地编写为同一脚本:但是“ python setup.py py2exe”返回了此消息(希望我正确翻译了此消息)译成英文):“命令'python'写错或找不到。” Why does this happen? 为什么会这样? How can I solve this? 我该如何解决?

This has nothing to do with py2exe , and everything to do with the machine's setup. 这与py2exe无关,与机器的设置无关。

You don't have python on your path. 您的路径上没有python You can test this by just running python by itself to open the interactive interpreter. 您可以通过仅运行python来打开交互式解释器来进行测试。 If cmd can't find python , it can't run it. 如果cmd找不到python ,它将无法运行。

Here are some ways around this: 以下是一些解决方法:

  • Explicitly use the full path to Python—eg, if it's C:\\Python27\\bin\\Python.exe , type that instead of just python . 显式使用Python的完整路径-例如,如果它是C:\\Python27\\bin\\Python.exe ,请键入它而不是python
  • Temporarily edit your PATH environment variable in the cmd window. cmd窗口中临时编辑PATH环境变量。 With the above example, this would be set PATH=%PATH%;C:\\Python27\\bin . 在上面的示例中,将其set PATH=%PATH%;C:\\Python27\\bin You will have to do this again every time you reboot, open a new cmd window, etc. 每次重新启动,打开新的cmd窗口等时,都必须再次执行此操作。
  • Permanently edit your PATH environment variable. 永久编辑您的PATH环境变量。 This is done in the Advanced System Settings controls, which I believe are still accessible through the Properties on the context menu for My Computer in Windows 7. 这是在“高级系统设置”控件中完成的,我相信仍可以通过Windows 7中“我的电脑”的上下文菜单上的“属性”进行访问。
  • Uninstall and reinstall Python, and this time allow it to put itself on your path. 卸载并重新安装Python,这次允许它放置在您的路径上。
  • Ask for further help at superuser or some other site that's focused on system configuration problems rather than programming problems. 在超级用户或其他专注于系统配置问题而非编程问题的站点上寻求进一步的帮助。

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

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