python小白一枚 求大神指點!
uj5u.com熱心網友回復:
可能是路徑中存在中文的原因吧,你把自己名字換成英文試試!!!!uj5u.com熱心網友回復:
用的版本對不對?版本一般是一一對應的uj5u.com熱心網友回復:
編碼問題,問題顯示的是UTF8無法解碼。uj5u.com熱心網友回復:
安裝jieba庫也出現了如下問題,安裝庫就容易出現問題 也不知道是什么原因Collecting jieba
Downloading jieba-0.42.1.tar.gz (19.2 MB)
| | 10 kB 740 bytes/s eta 7:12:13ERROR: Exception:
Traceback (most recent call last):
File "C:\Users\于鎮寧\AppData\Roaming\Python\Python36\site-packages\pip\_vendor\urllib3\response.py", line 425, in _error_catcher
yield
File "C:\Users\于鎮寧\AppData\Roaming\Python\Python36\site-packages\pip\_vendor\urllib3\response.py", line 507, in read
data = self._fp.read(amt) if not fp_closed else b""
File "C:\Users\于鎮寧\AppData\Roaming\Python\Python36\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 62, in read
data = self.__fp.read(amt)
File "c:\program files\python36\lib\http\client.py", line 449, in read
n = self.readinto(b)
File "c:\program files\python36\lib\http\client.py", line 493, in readinto
n = self.fp.readinto(b)
File "c:\program files\python36\lib\socket.py", line 586, in readinto
return self._sock.recv_into(b)
File "c:\program files\python36\lib\ssl.py", line 1009, in recv_into
return self.read(nbytes, buffer)
File "c:\program files\python36\lib\ssl.py", line 871, in read
return self._sslobj.read(len, buffer)
File "c:\program files\python36\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 "C:\Users\于鎮寧\AppData\Roaming\Python\Python36\site-packages\pip\_internal\cli\base_command.py", line 188, in _main
status = self.run(options, args)
File "C:\Users\于鎮寧\AppData\Roaming\Python\Python36\site-packages\pip\_internal\cli\req_command.py", line 185, in wrapper
return func(self, options, args)
File "C:\Users\于鎮寧\AppData\Roaming\Python\Python36\site-packages\pip\_internal\commands\install.py", line 333, in run
reqs, check_supported_wheels=not options.target_dir
File "C:\Users\于鎮寧\AppData\Roaming\Python\Python36\site-packages\pip\_internal\resolution\legacy\resolver.py", line 179, in resolve
discovered_reqs.extend(self._resolve_one(requirement_set, req))
File "C:\Users\于鎮寧\AppData\Roaming\Python\Python36\site-packages\pip\_internal\resolution\legacy\resolver.py", line 362, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "C:\Users\于鎮寧\AppData\Roaming\Python\Python36\site-packages\pip\_internal\resolution\legacy\resolver.py", line 314, in _get_abstract_dist_for
abstract_dist = self.preparer.prepare_linked_requirement(req)
File "C:\Users\于鎮寧\AppData\Roaming\Python\Python36\site-packages\pip\_internal\operations\prepare.py", line 469, in prepare_linked_requirement
hashes=hashes,
File "C:\Users\于鎮寧\AppData\Roaming\Python\Python36\site-packages\pip\_internal\operations\prepare.py", line 259, in unpack_url
hashes=hashes,
File "C:\Users\于鎮寧\AppData\Roaming\Python\Python36\site-packages\pip\_internal\operations\prepare.py", line 130, in get_http_url
link, downloader, temp_dir.path, hashes
File "C:\Users\于鎮寧\AppData\Roaming\Python\Python36\site-packages\pip\_internal\operations\prepare.py", line 281, in _download_http_url
for chunk in download.chunks:
File "C:\Users\于鎮寧\AppData\Roaming\Python\Python36\site-packages\pip\_internal\cli\progress_bars.py", line 166, in iter
for x in it:
File "C:\Users\于鎮寧\AppData\Roaming\Python\Python36\site-packages\pip\_internal\network\utils.py", line 39, in response_chunks
decode_content=False,
File "C:\Users\于鎮寧\AppData\Roaming\Python\Python36\site-packages\pip\_vendor\urllib3\response.py", line 564, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "C:\Users\于鎮寧\AppData\Roaming\Python\Python36\site-packages\pip\_vendor\urllib3\response.py", line 529, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "c:\program files\python36\lib\contextlib.py", line 99, in __exit__
self.gen.throw(type, value, traceback)
File "C:\Users\于鎮寧\AppData\Roaming\Python\Python36\site-packages\pip\_vendor\urllib3\response.py", line 430, 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.
uj5u.com熱心網友回復:
感謝各位的幫助!uj5u.com熱心網友回復:
所以應該怎么解決呀大佬uj5u.com熱心網友回復:
所以解決方法是在目錄的任何一個檔案夾都不要設定中文,因為中文是UTF-8!uj5u.com熱心網友回復:
1.先說貼代碼問題
請參考
學會貼圖和貼代碼 - csdn的bbs論壇 · Python新手小白常見錯誤和問題
去改為 格式化的 彩色的代碼 便于閱讀
2. 再說此處具體問題:
(1)socket.timeout: The read operation timed out
指的是:網路方面的超時了 -》最典型的就是網路連接超時了
(2)pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
含義:從files.pythonhosted.org這里下載檔案(你此處的jieba等python的庫)超時了
原因:國內網路連接files.pythonhosted.org,經常速度很慢,有時候徹底連不上。當連不上時,就會報告此錯誤
額外說明:
此處的 Downloading jieba-0.42.1.tar.gz 沒有顯示細節,有些時候會顯示細節,你就能看到你要下載的檔案jieba-0.42.1.tar.gz,是來自于files.pythonhosted.org的
如何解決:
兩種辦法:
辦法1:科學上網加代理-》就能連上了
如果不會科學上網,可以參考我的:
科學上網相關知識總結
辦法2:換python的pip的源
具體操作:
新建(全域的系統的)pip的組態檔
Windows系統是:
%HOMEPATH%\pip\pip.ini
比如:
C:\Users\Administrator\pip\pip.ini
然后再去給組態檔加上國內的某個pip的源
比如 清華大學的pip的源
設定檔案內容是:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=pypi.tuna.tsinghua.edu.cn
然后再去用pip安裝python庫,就(不會從files.pythonhosted.org,而是)從此處設定的 pypi.tuna.tsinghua.edu.cn 去下載和安裝了。-》國內網路連的速度快。
另:
抽慷訓整理并發布相關教程:
Python心得:包管理器
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/24819.html
