I know this looks like a question answered thousands of time, but none of the traditional answers concerning the environment PATH are working.
I want to run the following in Windows 7, in Powershell:
python mycode.pyHowever, Powershell returns an error, stating that python not recognized as an applet, function, application,...
These are my path variables:
Users variables:
PATH C:\Python27\Lib\site-packages\PyQt4;C:\Python27;C:\Python27\DLLs;C:\Python27\Scripts;C:\Python27\Lib\site-packages\vtk;C:\Python27\gnuplot\binary;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\binPATHEXT .PY;.PYWPYTHON_INCLUDE C:\Python27\includePYTHON_LIB C:\Python27\libs\python27.liband System variables:
PATHC:\Python27\Lib\site-packages\PyQt4;C:\Python27;C:\Python27\DLLs;C:\Python27\Scripts;C:\Python27\Lib\site-packages\vtk;C:\Python27\gnuplot\binary;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;C:\WINDOWS\system32;C:\WINDOWSI tried the following:
$env:Path = $env:Path +";C:\Python27\"[Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Python27", "User")without success. (I tried starting a new Powershell session, of course, and even tried to reboot my PC)
Could it be that PowerShell doesn't properly read the path variable, or I don't have some permission? I am lost, especially knowing that this work fine on another Windows 7 install. I note that typing:
python.exe...opens a Python terminal as expected.
Edit : Ok I tried the following test.py code :
# -*- coding: utf-8 -*-print "Hello"input()python.exe test.pyopen a new terminal with "Hello" in it and wait for my inputbut I don't want that, I expect the normal behaviour, with "Hello" printed in PowerShell, error message in PowerShell and so on.
Edit2 : I noticed that the "Path" variable given in PowerShell by: Get-ChildItem Env
Is not equal to the one in the W7 options "System -> Advanced System settings -> Environment variable" . it was only :
;C:\Python27Like if my previous command line [Environment]::SetEnvironmentVariable("Path", "$env:Path;C:\Python27")just wrote in it. Fixing this didn't solve my problem either.