Setting python environment variables under windows system

Setting Python's environment variables on Windows allows you to run Python and pip commands globally from the command prompt (or PowerShell). Here are the steps on how to configure Python’s environment variables:

  1. Install Python:

    • When you download and install Python from its official website, the installer provides an option "Add Python to PATH". Make sure this option is checked to add Python to environment variables.

      If you already have Python installed and forgot to select this option, don't worry. You can manually add Python to the environment variables.

  2. Manually configure environment variables:

    • Open Control Panel > System > Advanced System Settings > Environment Variables.

    • In the System Variables section, find the variable named Path and select Edit.

    • In the Edit Environment Variables window, click "New" and add the Python installation path and Scripts subdirectory to the list. For example, if you installed Python in C:\Python39(this depends on your Python version), you would need to add the following two paths:

      makefile
      C:\Python39\ C:\Python39\Scripts\
      • The first path is the path to the Python interpreter.
      • The second path is the path to pip and some other scripts.
    • Click OK to save changes.

  3. Verify settings:

    • Open a new command prompt or PowerShell window.

    • Type python --versionand press Enter. This should show the Python version you have installed.

    • Type pip --versionand press Enter. This should show your pip version and the associated Python version.

Through the above steps, you should have successfully configured Python environment variables on Windows. Now, you can use python and pip commands from any command line or script.

Add my WeChat to communicate and discuss together

Guess you like

Origin blog.csdn.net/taoshihan/article/details/133028681