Why would I add python to PATH

前端 未结 2 581
轻奢々
轻奢々 2020-12-23 16:55

I am beginning to look at python, so when I found a tutorial it said that the first thing to do would be to download python from www.python.org/downloads/

Now when I

相关标签:
2条回答
  • 2020-12-23 17:45

    PATH is an environment variable in Windows. It basically tells the commandline what folders to look in when attempting to find a file. If you didn't add Python to PATH then you would call it from the commandline like this:

    C:/Python27/Python some_python_script.py
    

    Whereas if you add it to PATH, you can do this:

    python some_python_script.py
    

    Which is shorter and neater. It works because the command line will look through all the PATH folders for python and find it in the folder that the Python installer has added there.

    The reason it's unticked by default is partly because if you're installing multiple versions of Python, you probably want to be able to control which one your commandline will open by default, which is harder to do if both versions are being added to your PATH.

    0 讨论(0)
  • 2020-12-23 17:49

    In addition to what @SuperBiasedMan stated, you can edit your PATH in Windows by hitting Start > Run, then type sysdm.cpl. From there, navigate to Advanced tab and then hit Environment Variables. In the lower section, where it says 'System variables', find the one named PATH and double click it. Note that it would be easier to copy and paste it to a notepad or something. The separator as you can see is a semi-colon. Any path that you add to this variable, will be looked when you type any command in a cmd window or through the 'Run' command line. That's the same concept as in Linux, I just pointed out how it can be edited.

    0 讨论(0)
提交回复
热议问题