Adding Python Path on Windows 7

后端 未结 19 1636
盖世英雄少女心
盖世英雄少女心 2020-11-21 23:37

I\'ve been trying to add the Python path to the command line on Windows 7, yet no matter the method I try, nothing seems to work. I\'ve used the set command, I\

相关标签:
19条回答
  • 2020-11-22 00:11

    I know this post is old but I'd like to add that the solutions assume admin privs. If you don't have those you can:

    Go to control panel, type path (this is Windows 7 now so that's in the Search box) and click "Edit Environment variables for your account". You'll now see the Environment Variable dialog with "User variables" on the top and "System variables" below.

    You can, as a user, click the top "New" button and add:

    Variable name: PATH
    Variable value: C:\Python27

    (no spaces anywhere) and click OK. Once your command prompt is restarted, any PATH in the User variables is appended to the end of the System Path. It doesn't replace the PATH in any other way.

    If you want a specific full path set up, you're better off creating a batch file like this little one:

    @echo off
    PATH C:\User\Me\Programs\mingw\bin;C:\User\Me\Programs;C:\Windows\system32
    title Compiler Environment - %Username%@%Computername%
    cmd
    

    Call it "compiler.bat" or whatever and double click to start it. Or link to it. Or pin it etc...

    0 讨论(0)
  • 2020-11-22 00:13

    Working with Windows environment variables is always a horrible experience. Recently, I found an amazing tool called Rapid Environment Editor, which gives an awesomely simple GUI for managing them.

    If you use chocolatey, you can install it using choco install rapidee. Otherwise, take a look at http://www.rapidee.com/en/download

    Re-reading this, it sounds like a paid shill, but I swear I'm not! It's just been one of the most useful utilities in my toolkit for a while and I'm surprised no one seems to know about it.

    0 讨论(0)
  • 2020-11-22 00:14

    Python comes with a small utility that does just this. From the command line run:

    c:\python27\tools\scripts\win_add2path.py
    

    Make sure you close the command window (with exit or the close button) and open it again.

    0 讨论(0)
  • 2020-11-22 00:14

    If Python was installed with another program, such as ArcGIS 10.1 in my case, then you also must include any extra folders that path to the python.exe in your Environment Variables.

    So my Environment Variables looks like this:

    System variables > Path > add ;C:\Python27\ArcGIS10.1

    0 讨论(0)
  • 2020-11-22 00:16

    Make sure you don't add a space before the new directory.

    Good: old;old;old;new

    Bad: old;old;old; new

    0 讨论(0)
  • 2020-11-22 00:17
    1. Hold Win and press Pause.
    2. Click Advanced System Settings.
    3. Click Environment Variables.
    4. Append ;C:\python27 to the Path variable.
    5. Restart Command Prompt.
    0 讨论(0)
提交回复
热议问题