python三方包安装有两种方式
1、pip install方式
1)D:\tools\python\Python3.7.4\Scripts>pip install --index https://pypi.mirrors.ustc.edu.cn/simple/ <包名>
2)D:\tools\python\Python3.7.4\Scripts>pip install <包名> -i http://pypi.douban.com/simple/ --trusted-host pypi.douban.com
2、python setup.py install命令
在https://pypi.org/project网站下载需要的三方包
在cmd下进入三方包setup.py的目录,通过python setup.py install进行安装
我遇到的问题,由于网络代理限制,不能使用pip安装,所以需要将三方包下载下来安装通过python setup.py instal安装:
D:\tools\python\Python3.7.4\requests-2.22.0>python setup.py install
running install
running bdist_egg
running egg_info
writing requests.egg-info\PKG-INFO
writing dependency_links to requests.egg-info\dependency_links.txt
writing requirements to requests.egg-info\requires.txt
writing top-level names to requests.egg-info\top_level.txt
reading manifest file 'requests.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching 'NOTICE'
warning: no files found matching 'requirements.txt'
writing manifest file 'requests.egg-info\SOURCES.txt'
installing library code to build\bdist.win-amd64\egg
running install_lib
running build_py
creating build
creating build\lib
creating build\lib\requests
copying requests\adapters.py -> build\lib\requests
copying requests\api.py -> build\lib\requests
copying requests\auth.py -> build\lib\requests
copying requests\certs.py -> build\lib\requests
copying requests\compat.py -> build\lib\requests
copying requests\cookies.py -> build\lib\requests
copying requests\exceptions.py -> build\lib\requests
copying requests\help.py -> build\lib\requests
copying requests\hooks.py -> build\lib\requests
copying requests\models.py -> build\lib\requests
copying requests\packages.py -> build\lib\requests
copying requests\sessions.py -> build\lib\requests
copying requests\status_codes.py -> build\lib\requests
copying requests\structures.py -> build\lib\requests
copying requests\utils.py -> build\lib\requests
copying requests\_internal_utils.py -> build\lib\requests
copying requests\__init__.py -> build\lib\requests
copying requests\__version__.py -> build\lib\requests
creating build\bdist.win-amd64
creating build\bdist.win-amd64\egg
creating build\bdist.win-amd64\egg\requests
copying build\lib\requests\adapters.py -> build\bdist.win-amd64\egg\requests
copying build\lib\requests\api.py -> build\bdist.win-amd64\egg\requests
copying build\lib\requests\auth.py -> build\bdist.win-amd64\egg\requests
copying build\lib\requests\certs.py -> build\bdist.win-amd64\egg\requests
copying build\lib\requests\compat.py -> build\bdist.win-amd64\egg\requests
copying build\lib\requests\cookies.py -> build\bdist.win-amd64\egg\requests
copying build\lib\requests\exceptions.py -> build\bdist.win-amd64\egg\requests
copying build\lib\requests\help.py -> build\bdist.win-amd64\egg\requests
copying build\lib\requests\hooks.py -> build\bdist.win-amd64\egg\requests
copying build\lib\requests\models.py -> build\bdist.win-amd64\egg\requests
copying build\lib\requests\packages.py -> build\bdist.win-amd64\egg\requests
copying build\lib\requests\sessions.py -> build\bdist.win-amd64\egg\requests
copying build\lib\requests\status_codes.py -> build\bdist.win-amd64\egg\requests
copying build\lib\requests\structures.py -> build\bdist.win-amd64\egg\requests
copying build\lib\requests\utils.py -> build\bdist.win-amd64\egg\requests
copying build\lib\requests\_internal_utils.py -> build\bdist.win-amd64\egg\requests
copying build\lib\requests\__init__.py -> build\bdist.win-amd64\egg\requests
copying build\lib\requests\__version__.py -> build\bdist.win-amd64\egg\requests
byte-compiling build\bdist.win-amd64\egg\requests\adapters.py to adapters.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\requests\api.py to api.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\requests\auth.py to auth.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\requests\certs.py to certs.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\requests\compat.py to compat.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\requests\cookies.py to cookies.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\requests\exceptions.py to exceptions.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\requests\help.py to help.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\requests\hooks.py to hooks.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\requests\models.py to models.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\requests\packages.py to packages.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\requests\sessions.py to sessions.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\requests\status_codes.py to status_codes.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\requests\structures.py to structures.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\requests\utils.py to utils.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\requests\_internal_utils.py to _internal_utils.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\requests\__init__.py to __init__.cpython-37.pyc
byte-compiling build\bdist.win-amd64\egg\requests\__version__.py to __version__.cpython-37.pyc
creating build\bdist.win-amd64\egg\EGG-INFO
copying requests.egg-info\PKG-INFO -> build\bdist.win-amd64\egg\EGG-INFO
copying requests.egg-info\SOURCES.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying requests.egg-info\dependency_links.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying requests.egg-info\not-zip-safe -> build\bdist.win-amd64\egg\EGG-INFO
copying requests.egg-info\requires.txt -> build\bdist.win-amd64\egg\EGG-INFO
copying requests.egg-info\top_level.txt -> build\bdist.win-amd64\egg\EGG-INFO
creating dist
creating 'dist\requests-2.22.0-py3.7.egg' and adding 'build\bdist.win-amd64\egg' to it
removing 'build\bdist.win-amd64\egg' (and everything under it)
Processing requests-2.22.0-py3.7.egg
creating d:\tools\python\python3.7.4\lib\site-packages\requests-2.22.0-py3.7.egg
Extracting requests-2.22.0-py3.7.egg to d:\tools\python\python3.7.4\lib\site-packages
Adding requests 2.22.0 to easy-install.pth file
Installed d:\tools\python\python3.7.4\lib\site-packages\requests-2.22.0-py3.7.egg
Processing dependencies for requests==2.22.0
Searching for certifi>=2017.4.17
Reading https://pypi.org/simple/certifi/
Download error on https://pypi.org/simple/certifi/: Tunnel connection failed: 407 authenticationrequired -- Some packages may not be found!
Couldn't find index page for 'certifi' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.org/simple/
Download error on https://pypi.org/simple/: Tunnel connection failed: 407 authenticationrequired -- Some packages may not be found!
No local packages or working download links found for certifi>=2017.4.17
error: Could not find suitable distribution for Requirement.parse('certifi>=2017.4.17')
网上查了许久,终于找到原因
requests安装有依赖的包版本,如下:
certifi [required: >=2017.4.17] #CA认证模块
urllib3 [required:!=1.25.0,!=1.25.1,<1.26,>=1.21.1’ ] #线程安全HTTP库
idna [required: <2.9,>=2.5 ] #国际化域名解析模块
chardet [required:❤️.1.0,>=3.0.2] #通用字符编码检测器模块
分别下载进行安装,下面只给出其中一个的安装方法,其他的三个类似
cmd进入chardet文件的setup.py路径D:\tools\python\chardet-3.0.4\chardet-3.0.4>,使用python setup.py install进行安装
D:\tools\python\chardet-3.0.4\chardet-3.0.4>python setup.py install
running install
running bdist_egg
running egg_info
writing chardet.egg-info\PKG-INFO