Path to Python

Hi everyone,

I'm trying to run python from the command line on Windows 7. To do this I did the following:

(1) Clicked on the start menu then right-clicked on Computer and chose "Properties"
(2) I then chose "Advanced System Settings" then clicked on the "Environment Variables" button
(3) I scrolled down under "System Variables" and clicked on "Path" and then clicked edit

The following was the path

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\

Since python is installed on the C drive I appended that extra bit to the path so it now looks like this:

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Python27

Then in the command line I typed in:

python merge_csv.py

When I pressed enter, I got the following error:

'python' is not recognized as an internal or external command, operable program or batch file.

Can anyone tell me what the error means and how I can set the path correctly so it will run?

I'd really be grateful for any advice.
LVL 1
gwh2Asked:
Who is Participating?
 
Kim RyanConnect With a Mentor IT ConsultantCommented:
You need a ; at the end of your PATH. Also type 'path' on the command line to confirm it is set right. You still may need to use ;%SystemRoot% instead of C:
0
 
Kim RyanIT ConsultantCommented:
Try typing
python.exe merge_csv.py
0
 
gwh2Author Commented:
Thanks for the reply. I tried typing that but I get the same error. Any other suggestions would be appreciated.
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
phoffricConnect With a Mentor Commented:
What do you get when you enter "path" from the Command Prompt where you try to enter "python" ? I get:
C:\Python27>path
PATH=C:\Python27\;C:\....etc

Open in new window

If you do not find the C:\Python27\ path, then try restarting Windows 7.
Possibly it may help to add a \ after C:Python as I have done. I have read that there may be other paths that can cause problems, so putting it up front may possibly help. Make sure that you did not add a space after the last semicolon if you keep the python path at the end.

I put the python path at the beginning because I was learning python for awhile. Putting it at the end as you have done is probably the right thing to do. But, you can experiment, by putting it in the beginning of the path.


What do you get when you cd to the C:\Python27 and then enter "dir" ? I get:
C:\Python27>dir
 Directory of C:\Python27

05/29/2013  08:31 PM    <DIR>          .
05/29/2013  08:31 PM    <DIR>          ..
05/29/2013  08:31 PM    <DIR>          DLLs
05/29/2013  08:31 PM    <DIR>          Doc
05/29/2013  08:31 PM    <DIR>          include
11/22/2016  12:21 AM    <DIR>          Lib
05/29/2013  08:31 PM    <DIR>          libs
04/10/2012  10:34 PM            40,092 LICENSE.txt
07/29/2008  08:10 AM             1,857 Microsoft.VC90.CRT.manifest
07/29/2008  08:05 AM           655,872 msvcr90.dll
04/10/2012  10:18 PM           310,875 NEWS.txt
04/10/2012  10:31 PM            26,624 python.exe   <-- of course, you probably have this, right?
04/10/2012  10:31 PM         2,303,488 python27.dll
04/10/2012  10:31 PM            27,136 pythonw.exe
04/10/2012  10:18 PM            54,973 README.txt
05/29/2013  08:31 PM    <DIR>          tcl
05/29/2013  08:31 PM    <DIR>          Tools
04/10/2012  10:31 PM            49,664 w9xpopen.exe
               9 File(s)      3,470,581 bytes

Open in new window


What do you get when you enter "\python27\python" from your Windows directory? I get:
C:\Windows>  \python27\python
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Open in new window


Now, in that same directory, C:\Python27\, what do you get when you enter, "python" ? I get:
C:\Python27>python
Python 2.7.3 (default, Apr 10 2012, 23:31:26) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Open in new window

0
 
gwh2Author Commented:
Thanks again for the replies. I added in the final semi-colon and then typed in python again in the command line and I got a similar result, ie.

C:\Python27>python
Python 2.7.12 (v2.7.12:d33e0cf91556, Jun 27 2016) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Does that mean it's running and knows which file to look at?
0
 
Kim RyanIT ConsultantCommented:
Yes, you can use your full command now.
0
 
gwh2Author Commented:
That's great - thanks so much. Just one other question if that's ok: is there an easy way to create an alias of a .exe application file without using the command line? If not, would you be able to instruct me on how to create the alias? If I need to open up a new post please let me know.

Thanks again
0
 
phoffricCommented:
Did you add the backslash as suggested?
When you type in path, what do you get?
0
 
gwh2Author Commented:
No I didn't add the backslash. I found that I only needed to add the semi-colon at the end and then I was able to create the .exe file so it's all working as expected which is great. I just need to find out how to make an alias of the .exe file.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.