pip install jieba一直下载失败,未找到原因,崩溃中。。。。
C:\Users\50371\AppData\Local\Programs\Python\Python39>pip install jieba
Collecting jieba
Downloading jieba-0.42.1.tar.gz (19.2 MB)
|▌ | 399 kB 6.8 kB/s eta 0:46:22
ERROR: Exception:
Traceback (most recent call last):
File “C:\Users\50371\anaconda3\lib\site-packages\pip\_vendor\resolvelib\resolvers.py”, line 171, in _merge_into_criterion
crit = self.state.criteria[name]
KeyError: ‘jieba’
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “C:\Users\50371\anaconda3\lib\site-packages\pip\_vendor\urllib3\response.py”, line 438, in _error_catcher
yield
File “C:\Users\50371\anaconda3\lib\site-packages\pip\_vendor\urllib3\response.py”, line 519, in read
data = self._fp.read(amt) if not fp_closed else b””
File “C:\Users\50371\anaconda3\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py”, line 62, in read
data = self.__fp.read(amt)
File “C:\Users\50371\anaconda3\lib\http\client.py”, line 458, in read
n = self.readinto(b)
File “C:\Users\50371\anaconda3\lib\http\client.py”, line 502, in readinto
n = self.fp.readinto(b)
File “C:\Users\50371\anaconda3\lib\socket.py”, line 669, in readinto
return self._sock.recv_into(b)
File “C:\Users\50371\anaconda3\lib\ssl.py”, line 1241, in recv_into
return self.read(nbytes, buffer)
File “C:\Users\50371\anaconda3\lib\ssl.py”, line 1099, in read
return 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\50371\anaconda3\lib\site-packages\pip\_internal\cli\base_command.py”, line 189, in _main
status = self.run(options, args)
File “C:\Users\50371\anaconda3\lib\site-packages\pip\_internal\cli\req_command.py”, line 178, in wrapper
return func(self, options, args)
File “C:\Users\50371\anaconda3\lib\site-packages\pip\_internal\commands\install.py”, line 316, in run
requirement_set = resolver.resolve(
File “C:\Users\50371\anaconda3\lib\site-packages\pip\_internal\resolution\resolvelib\resolver.py”, line 121, in resolve
self._result = resolver.resolve(
File “C:\Users\50371\anaconda3\lib\site-packages\pip\_vendor\resolvelib\resolvers.py”, line 453, in resolve
state = resolution.resolve(requirements, max_rounds=max_rounds)
File “C:\Users\50371\anaconda3\lib\site-packages\pip\_vendor\resolvelib\resolvers.py”, line 318, in resolve
name, crit = self._merge_into_criterion(r, parent=None)
File “C:\Users\50371\anaconda3\lib\site-packages\pip\_vendor\resolvelib\resolvers.py”, line 173, in _merge_into_criterion
crit = Criterion.from_requirement(self._p, requirement, parent)
File “C:\Users\50371\anaconda3\lib\site-packages\pip\_vendor\resolvelib\resolvers.py”, line 82, in from_requirement
if not cands:
File “C:\Users\50371\anaconda3\lib\site-packages\pip\_vendor\resolvelib\structs.py”, line 124, in __bool__
return bool(self._sequence)
File “C:\Users\50371\anaconda3\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py”, line 143, in __bool__
return any(self)
File “C:\Users\50371\anaconda3\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py”, line 38, in _iter_built
candidate = func()
File “C:\Users\50371\anaconda3\lib\site-packages\pip\_internal\resolution\resolvelib\factory.py”, line 167, in _make_candidate_from_link
self._link_candidate_cache[link] = LinkCandidate(
File “C:\Users\50371\anaconda3\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py”, line 300, in __init__
super().__init__(
File “C:\Users\50371\anaconda3\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py”, line 144, in __init__
self.dist = self._prepare()
File “C:\Users\50371\anaconda3\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py”, line 226, in _prepare
dist = self._prepare_distribution()
File “C:\Users\50371\anaconda3\lib\site-packages\pip\_internal\resolution\resolvelib\candidates.py”, line 311, in _prepare_distribution
return self._factory.preparer.prepare_linked_requirement(
File “C:\Users\50371\anaconda3\lib\site-packages\pip\_internal\operations\prepare.py”, line 457, in prepare_linked_requirement
return self._prepare_linked_requirement(req, parallel_builds)
File “C:\Users\50371\anaconda3\lib\site-packages\pip\_internal\operations\prepare.py”, line 480, in _prepare_linked_requirement
local_file = unpack_url(
File “C:\Users\50371\anaconda3\lib\site-packages\pip\_internal\operations\prepare.py”, line 230, in unpack_url
file = get_http_url(
File “C:\Users\50371\anaconda3\lib\site-packages\pip\_internal\operations\prepare.py”, line 108, in get_http_url
from_path, content_type = download(link, temp_dir.path)
File “C:\Users\50371\anaconda3\lib\site-packages\pip\_internal\network\download.py”, line 163, in __call__
for chunk in chunks:
File “C:\Users\50371\anaconda3\lib\site-packages\pip\_internal\cli\progress_bars.py”, line 159, in iter
for x in it:
File “C:\Users\50371\anaconda3\lib\site-packages\pip\_internal\network\utils.py”, line 64, in response_chunks
for chunk in response.raw.stream(
File “C:\Users\50371\anaconda3\lib\site-packages\pip\_vendor\urllib3\response.py”, line 576, in stream
data = self.read(amt=amt, decode_content=decode_content)
File “C:\Users\50371\anaconda3\lib\site-packages\pip\_vendor\urllib3\response.py”, line 541, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File “C:\Users\50371\anaconda3\lib\contextlib.py”, line 131, in __exit__
self.gen.throw(type, value, traceback)
File “C:\Users\50371\anaconda3\lib\site-packages\pip\_vendor\urllib3\response.py”, line 443, 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 -i https://pypi.tuna.tsinghua.edu.cn/simple jieba
试了下,果然几秒钟就成功了。
兴致勃勃的去运行了下程序,还是报错了
ModuleNotFoundError: No module named ‘jie ba’
于是继续找原因,发现可能是安装路径有问题,默认安装到了anaconda库里,但我用的是python。那就需要改安装路径。
pip install --target=\C:\Users\50371\AppData\Local\Programs\Python\Python39\Lib\site-packages jieba
成功了
除了改变安装路径,也可以通过改变环境变量来解决,将python的环境变量放在anaconda之前即可。