本文目錄一覽:
如何安裝python的第三方模塊
通過pip來安裝python模塊
安裝 easy_install pip
D:\workeasy_install pip
Searching for pip
Best match: pip 6.1.1
Processing pip-6.1.1-py2.7.egg
pip 6.1.1 is already the active version in easy-install.pth
Installing pip-script.py script to C:\Python27\Scripts
Installing pip.exe script to C:\Python27\Scripts
Installing pip2.7-script.py script to C:\Python27\Scripts
Installing pip2.7.exe script to C:\Python27\Scripts
Installing pip2-script.py script to C:\Python27\Scripts
Installing pip2.exe script to C:\Python27\Scripts
Using c:\python27\lib\site-packages\pip-6.1.1-py2.7.egg
Processing dependencies for pip
Finished processing dependencies for pip
運行 pip install xlrd
Usage:
pip command [options]
Commands:
install Install packages.
uninstall Uninstall packages.
freeze Output installed packages in requirements format.
list List installed packages.
show Show information about installed packages.
search Search PyPI for packages.
wheel Build wheels from your requirements.
zip DEPRECATED. Zip individual packages.
unzip DEPRECATED. Unzip individual packages.
help Show help for commands.
General Options:
-h, –help Show help.
–isolated Run pip in an isolated mode, ignoring
environment variables and user configuration.
-v, –verbose Give more output. Option is additive, and can be
used up to 3 times.
-V, –version Show version and exit.
-q, –quiet Give less output.
–log path Path to a verbose appending log.
–proxy proxy Specify a proxy in the form
[user:passwd@]proxy.server:port.
–retries retries Maximum number of retries each connection should
attempt (default 5 times).
–timeout sec Set the socket timeout (default 15 seconds).
–exists-action action Default action when a path already exists:
(s)witch, (i)gnore, (w)ipe, (b)ackup.
–trusted-host hostname Mark this host as trusted, even though it does
not have valid or any HTTPS.
–cert path Path to alternate CA bundle.
–client-cert path Path to SSL client certificate, a single file
containing the private key and the certificate
in PEM format.
–cache-dir dir Store the cache data in dir.
–no-cache-dir Disable the cache.
–disable-pip-version-check
Don’t periodically check PyPI to determine
whether a new version of pip is available for
download. Implied with –no-index.
python庫安裝錯誤 in _error_catcher解決之鏡像安裝(轉)非常好用
pip install grpcio-tools
1、出現如下錯誤:
Traceback (most recent call last):
File “d:\usedtool\python\lib\site-packages\pip\_vendor\urllib3\response.py”, line 302, in _error_catcher
yield
File “d:\usedtool\python\lib\site-packages\pip\_vendor\urllib3\response.py”, line 384, in read
data = self._fp.read(amt)
File “d:\usedtool\python\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py”, line 60, in read
data = self.__fp.read(amt)
File “d:\usedtool\python\lib\http\client.py”, line 449, in read
n = self.readinto(b)
File “d:\usedtool\python\lib\http\client.py”, line 493, in readinto
n = self.fp.readinto(b)
File “d:\usedtool\python\lib\socket.py”, line 586, in readinto
return self._sock.recv_into(b)
File “d:\usedtool\python\lib\ssl.py”, line 1009, in recv_into
return self.read(nbytes, buffer)
File “d:\usedtool\python\lib\ssl.py”, line 871, in read
return self._sslobj.read(len, buffer)
File “d:\usedtool\python\lib\ssl.py”, line 631, in read
v = self._sslobj.read(len, buffer)
socket.timeout: The read operation timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “d:\usedtool\python\lib\site-packages\pip\_internal\basecommand.py”, line 228, in main
status = self.run(options, args)
File “d:\usedtool\python\lib\site-packages\pip\_internal\commands\install.py”, line 291, in run
resolver.resolve(requirement_set)
File “d:\usedtool\python\lib\site-packages\pip\_internal\resolve.py”, line 103, in resolve
self._resolve_one(requirement_set, req)
File “d:\usedtool\python\lib\site-packages\pip\_internal\resolve.py”, line 257, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File “d:\usedtool\python\lib\site-packages\pip\_internal\resolve.py”, line 210, in _get_abstract_dist_for
self.require_hashes
File “d:\usedtool\python\lib\site-packages\pip\_internal\operations\prepare.py”, line 310, in prepare_linked_requirement
progress_bar=self.progress_bar
File “d:\usedtool\python\lib\site-packages\pip\_internal\download.py”, line 837, in unpack_url
progress_bar=progress_bar
File “d:\usedtool\python\lib\site-packages\pip\_internal\download.py”, line 674, in unpack_http_url
progress_bar)
File “d:\usedtool\python\lib\site-packages\pip\_internal\download.py”, line 898, in _download_http_url
_download_url(resp, link, content_file, hashes, progress_bar)
File “d:\usedtool\python\lib\site-packages\pip\_internal\download.py”, line 618, in _download_url
hashes.check_against_chunks(downloaded_chunks)
File “d:\usedtool\python\lib\site-packages\pip\_internal\utils\hashes.py”, line 48, in check_against_chunks
for chunk in chunks:
File “d:\usedtool\python\lib\site-packages\pip\_internal\download.py”, line 586, in written_chunks
for chunk in chunks:
File “d:\usedtool\python\lib\site-packages\pip\_internal\utils\ui.py”, line 159, in iter
for x in it:
File “d:\usedtool\python\lib\site-packages\pip\_internal\download.py”, line 575, in resp_read
decode_content=False):
File “d:\usedtool\python\lib\site-packages\pip\_vendor\urllib3\response.py”, line 436, in stream
data = self.read(amt=amt, decode_content=decode_content)
File “d:\usedtool\python\lib\site-packages\pip\_vendor\urllib3\response.py”, line 401, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File “d:\usedtool\python\lib\contextlib.py”, line 99, in __exit__
self.gen.throw(type, value, traceback)
File “d:\usedtool\python\lib\site-packages\pip\_vendor\urllib3\response.py”, line 307, in _error_catcher
raise ReadTimeoutError(self._pool, None, ‘Read timed out.’)
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host=’files.pythonhosted.org’, port=443): Read timed out.
解決方案:pip install grpcio-tools -i
後面的-i 即是鏡像
———————
原文: ( 侵刪,感謝! )
python 第三方庫怎麼安裝
【方法一】: 通過setuptools來安裝python模塊
首先下載
NOTE: 最好下載個setuptools,本人是15.2版本,裡面包含了ez_setup
運行 python ez_setup.py
D:\work\installation\setuptools-15.2\setuptools-15.2python ez_setup.py 1.txt
Extracting in c:\users\admini~1\appdata\local\temp\tmpbxikxf
Now working in c:\users\admini~1\appdata\local\temp\tmpbxikxf\setuptools-15.2
Installing Setuptools
……
Copying setuptools-15.2-py2.7.egg to c:\python27\lib\site-packages
setuptools 15.2 is already the active version in easy-install.pth
Installing easy_install-script.py script to C:\Python27\Scripts
Installing easy_install.exe script to C:\Python27\Scripts
Installing easy_install-2.7-script.py script to C:\Python27\Scripts
Installing easy_install-2.7.exe script to C:\Python27\Scripts
Installed c:\python27\lib\site-packages\setuptools-15.2-py2.7.egg
Processing dependencies for setuptools==15.2
Finished processing dependencies for setuptools==15.2
運行 easy_install py
D:\workeasy_install py #py 為第三方庫文件
Searching for py
Best match: py 1.4.26
Adding py 1.4.26 to easy-install.pth file
Using c:\python27\lib\site-packages
Processing dependencies for py
Finished processing dependencies for py
【方法二】: 通過pip來安裝python模塊
安裝 easy_install pip
D:\workeasy_install pip
Searching for pip
Best match: pip 6.1.1
Processing pip-6.1.1-py2.7.egg
pip 6.1.1 is already the active version in easy-install.pth
Installing pip-script.py script to C:\Python27\Scripts
Installing pip.exe script to C:\Python27\Scripts
Installing pip2.7-script.py script to C:\Python27\Scripts
Installing pip2.7.exe script to C:\Python27\Scripts
Installing pip2-script.py script to C:\Python27\Scripts
Installing pip2.exe script to C:\Python27\Scripts
Using c:\python27\lib\site-packages\pip-6.1.1-py2.7.egg
Processing dependencies for pip
Finished processing dependencies for pip
運行 pip install xlrd
Usage:
pip command [options]
Commands:
install Install packages.
uninstall Uninstall packages.
freeze Output installed packages in requirements format.
list List installed packages.
show Show information about installed packages.
search Search PyPI for packages.
wheel Build wheels from your requirements.
zip DEPRECATED. Zip individual packages.
unzip DEPRECATED. Unzip individual packages.
help Show help for commands.
General Options:
-h, –help Show help.
–isolated Run pip in an isolated mode, ignoring
environment variables and user configuration.
-v, –verbose Give more output. Option is additive, and can be
used up to 3 times.
-V, –version Show version and exit.
-q, –quiet Give less output.
–log path Path to a verbose appending log.
–proxy proxy Specify a proxy in the form
[user:passwd@]proxy.server:port.
–retries retries Maximum number of retries each connection should
attempt (default 5 times).
–timeout sec Set the socket timeout (default 15 seconds).
–exists-action action Default action when a path already exists:
(s)witch, (i)gnore, (w)ipe, (b)ackup.
–trusted-host hostname Mark this host as trusted, even though it does
not have valid or any HTTPS.
–cert path Path to alternate CA bundle.
–client-cert path Path to SSL client certificate, a single file
containing the private key and the certificate
in PEM format.
–cache-dir dir Store the cache data in dir.
–no-cache-dir Disable the cache.
–disable-pip-version-check
Don’t periodically check PyPI to determine
whether a new version of pip is available for
download. Implied with –no-index.
【方法三】:直接從網上下載下可執行文件來安裝.
比如說,去 pythonlibs 網站,提供了很多Python非官方包下載,二進位文件,下載安裝方便.
原創文章,作者:小藍,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/219561.html