当前位置:   article > 正文

安装python2.7以及第三方库_python2.7的wheel第三方库

python2.7的wheel第三方库

安装python2.7以及第三方库

安装python2.7

打开以下.condarc文件

C:\Users\xx\.condarc
  • 1

在该文件中添加

channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
show_channel_urls: true
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

不要加其他channels,不然可能会报下列错误

(base) C:\Users\wu520>conda create -n py27 python=2.7
Collecting package metadata (current_repodata.json): failed

UnavailableInvalidChannel: HTTP 404 NOT FOUND for channel pypi/simple <http://mirrors.aliyun.com/pypi/simple>

The channel is not accessible or is invalid.

You will need to adjust your conda configuration to proceed.
Use `conda config --show channels` to view your configuration's current state,
and use `conda config --show-sources` to view config file locations.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

成功界面如下

(base) C:\Users\wu520>conda create -n py27 python=2.7
Collecting package metadata (current_repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: E:\Anaconda\envs\py27

  added / updated specs:
    - python=2.7


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    certifi-2020.6.20          |     pyhd3eb1b0_3         155 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    pip-20.0.2                 |           py27_1         1.9 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    python-2.7.15              |h2880e7c_1011_cpython        20.3 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    python_abi-2.7             |          1_cp27m           4 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    setuptools-36.4.0          |           py27_1         525 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
    vc-9                       |       h2eaa2aa_6           5 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
    vs2008_runtime-9.0.30729.6161|                0         1.0 MB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    wheel-0.36.2               |     pyhd3deb0d_0          31 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    wincertstore-0.2           |  pyhd8ed1ab_1009          11 KB  https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
    ------------------------------------------------------------
                                           Total:        24.0 MB
done
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28

安装python2.7第三方库

参考:https://blog.csdn.net/weixin_46018884/article/details/126333114

直接安装一般会报错

(py27) C:\Users\wu520>pip install requests
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. A future version of pip will drop support for Python 2.7. More details about Python 2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
ERROR: Could not find a version that satisfies the requirement request (from versions: none)
ERROR: No matching distribution found for request
  • 1
  • 2
  • 3
  • 4

解决方法:

进入到 https://bootstrap.pypa.io/pip/2.7/get-pip.py中把里面的代码复制出来,再/py27/Scripts/(我的目录:E:\Anaconda\envs\py27\Scripts)目录下创建一个get-pip.py的文件粘贴刚才的代码,执行下列命令

python get-pip.py
  • 1
(py27) E:\Anaconda\envs\py27\Scripts>python get-pip.py
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Collecting pip<21.0
  Downloading pip-20.3.4-py2.py3-none-any.whl (1.5 MB)
     |████████████████████████████████| 1.5 MB 268 kB/s
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.0.2
    Uninstalling pip-20.0.2:
      Successfully uninstalled pip-20.0.2
Successfully installed pip-20.3.4
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11

接下来便可pip安装,以requests为例(可以不在Scripts目录下安装)

(py27) E:\Anaconda\envs\py27\Scripts>pip install requests
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Collecting requests
  Downloading requests-2.27.1-py2.py3-none-any.whl (63 kB)
     |████████████████████████████████| 63 kB 268 kB/s
Collecting idna<3,>=2.5; python_version < "3"
  Downloading idna-2.10-py2.py3-none-any.whl (58 kB)
     |████████████████████████████████| 58 kB 874 kB/s
Requirement already satisfied: certifi>=2017.4.17 in e:\anaconda\envs\py27\lib\site-packages (from requests) (2020.6.20)
Collecting chardet<5,>=3.0.2; python_version < "3"
  Downloading chardet-4.0.0-py2.py3-none-any.whl (178 kB)
     |████████████████████████████████| 178 kB 1.3 MB/s
Collecting urllib3<1.27,>=1.21.1
  Downloading urllib3-1.26.16-py2.py3-none-any.whl (143 kB)
     |████████████████████████████████| 143 kB 1.1 MB/s
Installing collected packages: idna, chardet, urllib3, requests
Successfully installed chardet-4.0.0 idna-2.10 requests-2.27.1 urllib3-1.26.16
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17

或者直接再这里找.whl轮子文件

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】

推荐阅读
相关标签