在安装了3.5版本之后,如何从Win7 Powershell启动Python 2.7?

15 浏览
0 Comments

在安装了3.5版本之后,如何从Win7 Powershell启动Python 2.7?

我刚刚在一个同时安装了Python 2.7的win7操作系统上安装了Python 3.5.1。现在在Powershell中输入“python”会启动3.5.1版本。以前是启动2.7版本。

现在如何启动2.7版本呢?输入“python27”或“Python27”、“python2.7”或“Python2.7”都不行。我的用户环境变量中有“C:\Python;”。

在阅读了这个讨论之后:Python 2 and 3 from Powershell

和参考的文章之后:

http://windowsitpro.com/powershell/take-charge-environment-variables-powershell

我是否正确地理解了,Powershell只能使用其中一个版本,也就是说,如果我想在Powershell中使用2.7版本,我必须激活和停用它?

是否有一种简单地输入“python27”来启动2.7版本的方法?

如果有帮助的话,这是我的用户环境PATH

C:\Users\patrick\AppData\Local\Programs\Python\Python35-32\Scripts\;

C:\Users\patrick\AppData\Local\Programs\Python\Python35-32\;

C:\ProgramData\Oracle\Java\javapath;

C:\Program Files\Common Files\Microsoft Shared\Windows Live;

C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;

C:\Windows\system32;

C:\Windows;

C:\Windows\System32\Wbem;

C:\Windows\System32\WindowsPowerShell\v1.0\;

C:\Program Files (x86)\Windows Live\Shared;

C:\Program Files (x86)\Common Files\Roxio Shared\DLLShared\;

C:\Program Files (x86)\Common Files\Roxio Shared\12.0\DLLShared\;

C:\Program Files\WIDCOMM\Bluetooth Software\;

C:\Program Files\WIDCOMM\Bluetooth Software\syswow64;

C:\Program Files (x86)\QuickTime\QTSystem\;

C:\Program Files (x86)\Skype\Phone\;

C:\Program Files\MATLAB\R2015b\bin;

C:\ffmpeg\bin;

C:\Python27;

C:\SQLite3

0
0 Comments

问题的原因是在安装了Python 3.5之后,无法在Win7 Powershell中启动Python 2.7。解决方法是使用WinPython发行版,并在其中打开winpython command prompt,这样就可以在特定的Python版本中调用Python 2.7。

0
0 Comments

在Windows 7的PowerShell中安装了Python 3.5之后,无法使用Python 2.7的问题。解决方法是使用Python安装时放置在$env:SYSTEMROOT(通常为C:\Windows)下的一个名为py.exe的可执行文件来指定要运行的版本。通过传递选项"-2"来启动已安装的Python 2.x版本,传递选项"-3"来启动已安装的Python 3.x版本(默认是2.x版本)。因此,可以使用以下命令从PowerShell运行Python 2.x脚本:py.exe -2 ...。

0