Вопрос

Python 2.7 is installed on C:/Python27 (through python(x,y) package). Windows 8.1 x64. How do I make Python 2.7 run from CMD ?

I want to do this as I am following "Learn Python The Hard Way" book and I got stuck on Excercise 0: The Setup.

I have tried:

  • Powershell [Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Python27", "User")
  • Adding Python to Windows PATH (both through the Control Panel and terminal).
  • Copying a python.bat file with @C:\Python27\python.exe %* to the system32.
  • Running CMD both as adminstrator and the regualr way.
  • Restarting CMD and PC between operations.

Both python and call python executed in CMD return 'python' is not recognized message. If I enter in CMD C:\Python27\python.exe then Python starts properly.

User variable Path for me:

C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files\OpenVPN\bin;C:\Program Files\Calibre2\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files\OpenVPN\bin;C:\Program Files\Calibre2\;C:\Python27\Lib\site-packages\PyQt4;C:\MiKTeX\miktex\bin\;C:\Python27;C:\Python27\DLLs;C:\Python27\Scripts;C:\Python27\Lib\site-packages\vtk;C:\Python27\gnuplot\binary;C:\Python27\Lib\site-packages\osgeo;C:\Program Files (x86)\pythonxy\SciTE-3.3.2-3;C:\Program Files (x86)\pythonxy\console;C:\MinGW32-xy\bin;C:\Program Files (x86)\pythonxy\swig;C:\Program Files (x86)\pythonxy\gettext\bin

System variable Path:

C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files (x86)\Intel\OpenCL SDK\2.0\bin\x64;C:\Program Files\OpenVPN\bin;C:\Program Files\Calibre2\;C:\Python27\Lib\site-packages\PyQt4;C:\MiKTeX\miktex\bin\;C:\Python27;C:\Python27\DLLs;C:\Python27\Scripts;C:\Python27\Lib\site-packages\vtk;C:\Python27\gnuplot\binary;C:\Python27\Lib\site-packages\osgeo;C:\Program Files (x86)\pythonxy\SciTE-3.3.2-3;C:\Program Files (x86)\pythonxy\console;C:\MinGW32-xy\bin;C:\Program Files (x86)\pythonxy\swig;C:\Program Files (x86)\pythonxy\gettext\bin
Это было полезно?

Решение 3

Solved by not using python(x,y). I decided to switch because I did read that author of python(x,y) did not rely on official packages. Installed Anaconda - everything works.

Другие советы

I think you can add the location of the files in the PATH environment variable. Follow the steps: Go to My Computer->Right click->Properties->Advanced System Settings->Click Environmental Variables. Now click PATH and then click EDIT. In the variable value field, go to the end and append ';' (without quotes) and then add the absolute path of the .exe file which you want to run via your program.

I guess you are using an old cmd line window, check if C:\Python27; is really added to your current cmd line window's path by typing echo %path% (don't check this via control pannel), if it's not there, start a new cmd window. Then probably C:\Python27; will be there in %PATH% and python will be recognized as a cmd now.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top