开发者

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,

  1. Type: environment variables in the search bar

  2. Press the environment variables button

    Python on cmd path

  3. Edit PATH variable

    Python on cmd path

  4. Add path to PATH variable

    Python on cmd path

    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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜