简体   繁体   English

Python控制台无法从命令行正确启动

[英]Python console not launching properly from command line

I seem to have problem launching python from command line. 我似乎在从命令行启动python时遇到问题。 I tried various things with no success. 我尝试了各种尝试,但都没有成功。 Problem: When trying to run python from the command line, there is no response ie I do not get message about 'command not found' and console does not launch. 问题:尝试从命令行运行python ,没有响应,即我未收到有关“找不到命令”的消息,并且控制台无法启动。 Only option to open python console is to run C:\\Python34\\python.exe directly. 打开python控制台的唯一选择是直接运行C:\\Python34\\python.exe Running using python command does not work even when in the python directory but python.exe launches. 即使在python目录中,使用python命令运行也不起作用,但会启动python.exe Issue with the launching this way is that python console is launched in new window. 以这种方式启动的问题是在新窗口中启动了python控制台。 This whole problem is present only on one machine while on my other machine I am able to run python correctly and console launches in the command prompt window from which the python command was executed. 整个问题仅在一台计算机上存在,而在另一台计算机上,我能够正确运行python,并且控制台在从中执行python命令的命令提示符窗口中启动。

PATH is correctly set to C:\\Python34\\;C:\\Python34\\Scripts;... and where python correctly returns C:\\Python34\\python.exe . PATH正确设置为C:\\Python34\\;C:\\Python34\\Scripts;...where python正确返回C:\\Python34\\python.exe I verified that running other commands imported through PATH (such as javac ) run correctly. 我验证了运行通过PATH导入的其他命令(例如javac )是否可以正常运行。

Things I tried: 我尝试过的事情:

  • Completely re-installing python both with x86 and x64 python installations with no success. 使用x86和x64 python安装完全重新安装python,但没有成功。
  • Copy installation from my second machine and manually set the path variables - again no success. 从第二台计算机上复制安装并手动设置路径变量-再次没有成功。

Can anyone hint how to resolve this behavior? 谁能暗示如何解决此问题?

(Additional info: Win 8.1 x64, python 3.4.2) (其他信息:Win 8.1 x64,python 3.4.2)

Issue resolved. 问题解决了。 Since no feasible solution was found in 2 days, I decided to wipe all keys containing 'python' from registry as well as some files that were not parts of other programs. 由于两天内未找到可行的解决方案,因此我决定清除注册表中包含“ python”的所有键以及不属于其他程序的某些文件。 This resolved the issue after re-installing python. 重新安装python后,此问题得以解决。

If anyone finds the true cause of this misbehavior and other - less brutal - solution, please write it here for future reference. 如果有人找到导致这种不当行为和其他(不太残酷)解决方案的真正原因,请在此处写下以供将来参考。

Recent Python installer has option to add PATH. 最近的Python安装程序可以选择添加PATH。 If you didn't use it, you can register directory where python.exe is to PATH environment variable. 如果不使用它,则可以将python.exe的目录注册到PATH环境变量中。

But I prefer py launcher. 但是我更喜欢py启动器。 It may be installed via Python 3.3 or 3.4. 它可以通过Python 3.3或3.4安装。 With it, you can start Python via py or py -3.4 . 有了它,您可以通过pypy -3.4启动Python。

See https://docs.python.org/3/using/windows.html#python-launcher-for-windows 参见https://docs.python.org/3/using/windows.html#python-launcher-for-windows

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

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