Windows上使用Python2.7安装pip

之前一直遇到一个问题,就是在Windows上使用python2.7安装pip一直不成功,

当时安装的时候使用的脚本是 get-pip.py,安装命令就是 python get-pip.py,然后就报错:

R:\软件\编程软件\pip>python get-pip.py
C:\Program Files\Python2.7\lib\site-packages\distribute-0.6.14-py2.7.egg\setuptools\command\install_scripts.py:3: UserWarning: Module pip was already imported from c:\users\xxx\appdata\local\temp\tmpgvdznh\pip.zip\pip\__init__.py, but c:\program files\python2.7\lib\site-packages\pip-18.1-py2.7.egg is being added to sys.path
  from pkg_resources import Distribution, PathMetadata, ensure_directory
c:\users\xxx\appdata\local\temp\tmpgvdznh\pip.zip\pip\_vendor\requests\packages\urllib3\util\ssl_.py:318: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#snimissingwarning.
c:\users\xxx\appdata\local\temp\tmpgvdznh\pip.zip\pip\_vendor\requests\packages\urllib3\util\ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
Could not fetch URL https://pypi.python.org/simple/pip/: There was a problem confirming the ssl certificate: [Errno 1] _ssl.c:507: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version - skipping
Requirement already up-to-date: pip in c:\program files\python2.7\lib\site-packages\pip-18.1-py2.7.egg
Collecting wheel
c:\users\xxx\appdata\local\temp\tmpgvdznh\pip.zip\pip\_vendor\requests\packages\urllib3\util\ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  Could not fetch URL https://pypi.python.org/simple/wheel/: There was a problem confirming the ssl certificate: [Errno 1] _ssl.c:507: error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version - skipping
  Could not find a version that satisfies the requirement wheel (from versions: )
No matching distribution found for wheel
c:\users\xxx\appdata\local\temp\tmpgvdznh\pip.zip\pip\_vendor\requests\packages\urllib3\util\ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.

最后找到的解决方法是下载 安装 pip 所需的离线包进行离线安装,离线包包括以下三个:

  • python-2.7.6.msi
  • setuptools-41.0.1.zip
  • pip-18.1.tar.gz

既:

这三个离线包也可以直接从我的资源上下载,我把这三个资源包打包上传到我的资源中了:pip_python.zip 【这份资源下载不了了】

更新资源【2023-11-16】:https://download.csdn.net/download/u012332816/88540342

安装方法在安装包里面有,其实也很简单,就是先安装 setuptools,再安装 pip,(默认你已经安装了python2.7了,若没有安装python2.7,则可以先安装压缩包中的 python-2.7.6.msi 文件)既:

先安装 setuptools:
进入setuptools 文件夹,运行:python setup.py install

再安装 pip:
进入 pip 文件夹,运行:python setup.py install

最后可以设置一下环境变量,使得你在任何地方打开控制台都能使用 python 和 pip 命令,

设置方法是:

【右键此电脑】 -> 【属性】-> 【高级系统设置】-> 【高级】-> 【环境变量】-> 【编辑用户变量中的Path变量】-> 【新建两项】

注意:

  • 以上是Win10系统示范
  • Python路径下的Scripts路径也要添加到环境变量中,因为pip.exe 是放在scripts路径下的。

Windows7 或者 XP 用户可以使用如下所示设置(其实基本一样):

【右键此电脑】 -> 【属性】-> 【高级系统设置】-> 【高级】-> 【环境变量】-> 【编辑用户变量中的Path变量】-> 【把两个路径添加到环境变量的末尾】

图2图2

注意:

  • 环境变量这里的每一条路径需要添加一个分号“:’” 来隔开,
  • 两个路径分别是python所在的路径和pip所在的路径,既“C:\MyProgramFiles\Python27\;C:\MyProgramFiles\Python27\Scripts;”

经过以上设置之后,重新打开一个控制台窗口,输入python --version 和 pip --version,如果能看到版本号信息,就说明安装成功了,如下图所示:

图3

至此,Windows 上使用 python2.7 离线安装 pip 完成了。  

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值