Python on cmd path
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 a开发者_如何学Ct cmd in windows.
Thanks.
Control Panel, System, Advanced tab, Environment Variables (Windows XP). Edit PATH:
PATH=C:\Python26;C:\Windows;.... etc.
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')
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,
Type: environment variables in the search bar
Press the environment variables button
- Edit PATH variable
- Add path to PATH variable
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/
- 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.
精彩评论