Windows下安装Python模块时环境配置

  1. “Win +R”打开cmd终端,如果直接在里面使用pip命令的时候,要么出现“syntax invalid”,要么出现:
  2. 'pip' is not recognized as an internal or external command, operable program or batch file.

    此时需要将C:Python27Scripts添加到系统环境变量,我顺便将C:Python27python.exe也添加进了系统环境变量,要保证echo %PATH%能看到对应的目录。

  3. 再使用pip install pyserial就可以安装serial模块了,不过我的右如下提示,说我的版本过旧:
  4. C:Usersh144197>pip install pyserial
    Requirement already satisfied (use --upgrade to upgrade): pyserial in c:python27libsite-packages
    You are using pip version 8.1.1, however version 9.0.1 is available.
    You should consider upgrading via the 'python -m pip install --upgrade pip' command.

    照着提示做就好了,类似于linux下的shell。

  5. C:Usersh144197>python -m pip install --upgrade pip
    Collecting pip
      Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
        100% |¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€¨€| 1.3MB 80kB/s
    Installing collected packages: pip
      Found existing installation: pip 8.1.1
        Uninstalling pip-8.1.1:
          Successfully uninstalled pip-8.1.1
    Successfully installed pip-9.0.1

    现在就可以使用pip安装模块了。

  6. 爽吧。。。
原文地址:https://www.cnblogs.com/kent-hu/p/8016648.html