Solved

Path to Python

Posted on 2016-11-21
9
107 Views
Last Modified: 2016-11-22
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.
0
Comment
Question by:gwh2
  • 4
  • 3
  • 2
9 Comments
 
LVL 19

Expert Comment

by:Kim Ryan
ID: 41896929
Try typing
python.exe merge_csv.py
0
 
LVL 1

Author Comment

by:gwh2
ID: 41896931
Thanks for the reply. I tried typing that but I get the same error. Any other suggestions would be appreciated.
0
 
LVL 19

Accepted Solution

by:
Kim Ryan earned 250 total points
ID: 41896984
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
 
LVL 32

Assisted Solution

by:phoffric
phoffric earned 250 total points
ID: 41896995
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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 1

Author Comment

by:gwh2
ID: 41897008
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
 
LVL 19

Expert Comment

by:Kim Ryan
ID: 41897030
Yes, you can use your full command now.
0
 
LVL 1

Author Comment

by:gwh2
ID: 41897050
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
 
LVL 32

Expert Comment

by:phoffric
ID: 41897055
Did you add the backslash as suggested?
When you type in path, what do you get?
0
 
LVL 1

Author Comment

by:gwh2
ID: 41897057
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

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you get continual lockouts after changing your Active Directory password, there are several possible reasons.  Two of the most common are using other devices to access your email and stored passwords in the credential manager of windows.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
This Micro Tutorial will teach you the basics of configuring your computer to improve its speed. It will also teach you how to disable programs that are running in the background simultaneously. This will be demonstrated using Windows 7 operating…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now