2

How can I append python to path? I tried put the python root, .exe, libs folder, but nothin work. I just want run .py files at cmd in windows.

Thanks.

2
  • What env variable are you modifying? classpath is a java thing. For commands, cmd looks at PATH. Commented Feb 6, 2011 at 0:33
  • You do in fact need to add python to your path. However, that won't magically allow you to run .py files by calling them. You'll need to run them like python path/to/file.py Commented Feb 6, 2011 at 0:33

3 Answers 3

4

Control Panel, System, Advanced tab, Environment Variables (Windows XP). Edit PATH:

PATH=C:\Python26;C:\Windows;.... etc. 
Sign up to request clarification or add additional context in comments.

Comments

0

In Python, the PATH where the python interpreter has visibility is available from sys.path

>>>import sys >>>print sys.path 

If you want to new paths to be added that list, just append to it.

>>>sys.path.append('c:/new/path/to/lib') 

1 Comment

>>>print (sys.path) could be the new format?? I am just starting and that is what is working.
0

cmd has environment variables, commands that are recognized.

To add the python command to cmd, you have to add the path to the folder in the control panel's environment variables section, which calls the python.exe file in your PC's Python folder.

To do this,

  1. Type: environment variables in the search bar

  2. Press the environment variables button enter image description here

  3. Edit PATH variable enter image description here
  4. Add path to PATH variable enter image description here It varies for where you installed python, but for me it is at:

C:\Users\USERNAME\AppData\Local\Programs\Python\Python36-32

To find the python.exe file

The AppData folder might be invisible. If the case, the following website is a good reference on making invisible folders visible https://www.howtogeek.com/howto/windows-vista/show-hidden-files-and-folders-in-windows-vista/

  1. Apply changes and open a new cmd window.

For the pip command, the same steps apply, only that the pip.exe file is in the \Scripts folder.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.