neolee / wop-community

29 stars 19 forks source link

无法解析导入“termcolor” #331

Closed murmurfish closed 6 months ago

murmurfish commented 1 year ago

错误代码_20231013222223

neolee commented 1 year ago

打开你的终端命令行,逐一运行下面的几个命令,把每一个命令的输出结果贴上来:

Get-Command python
Get-Command python3
Get-Command pip
Get-Command pip3
python -V
python3 -V
pip -V
pip3 -V
murmurfish commented 1 year ago

PS C:\Users\HP> Get-Command python

CommandType Name Version Source


Application python.exe 3.11.41... C:\Users\HP\AppData\Local\Programs\Python\Python311\python.exe

PS C:\Users\HP> Get-Command python3

CommandType Name Version Source


Application python3.exe 0.0.0.0 C:\Users\HP\AppData\Local\Microsoft\WindowsApps\python3.exe

PS C:\Users\HP> Get-Command pip

CommandType Name Version Source


Application pip.exe 0.0.0.0 C:\Users\HP\AppData\Local\Programs\Python\Python311\Scripts\pip.exe

PS C:\Users\HP> Get-Command pip3

CommandType Name Version Source


Application pip3.exe 0.0.0.0 C:\Users\HP\AppData\Local\Programs\Python\Python311\Scripts\pip3.exe

PS C:\Users\HP> python -V Python 3.11.4 PS C:\Users\HP> python3 -V PS C:\Users\HP> pip -V pip 23.1.2 from C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip (python 3.11) PS C:\Users\HP> pip3 -V pip 23.1.2 from C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip (python 3.11)

neolee commented 1 year ago

继续:

pip install termcolor
pip list

结果是啥?

murmurfish commented 1 year ago

每次要求我更新都会下载到0.3/2.1MB中断,以下为结果:

PS C:\Users\HP\Desktop\个人\code\wop> ### pip install termcolor Collecting termcolor Downloading termcolor-2.3.0-py3-none-any.whl (6.9 kB) ERROR: Exception: Traceback (most recent call last): File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_vendor\urllib3\response.py", line 438, in _error_catcher yield File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_vendor\urllib3\response.py", line 561, in read data = self._fp_read(amt) if not fp_closed else b"" ^^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_vendor\urllib3\response.py", line 527, in _fp_read return self._fp.read(amt) if amt is not None else self._fp.read() ^^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_vendor\cachecontrol\filewrapper.py", line 90, in read data = self.__fp.read(amt) ^^^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 466, in read s = self.fp.read(amt) ^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\socket.py", line 706, in readinto return self._sock.recv_into(b) ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 1278, in recv_into return self.read(nbytes, buffer) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 1134, in read return self._sslobj.read(len, buffer) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TimeoutError: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\cli\base_command.py", line 169, in exc_logging_wrapper status = run_func(*args) ^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\cli\req_command.py", line 248, in wrapper return func(self, options, args) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\commands\install.py", line 377, in run requirement_set = resolver.resolve( ^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\resolution\resolvelib\resolver.py", line 92, in resolve result = self._result = resolver.resolve( ^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_vendor\resolvelib\resolvers.py", line 546, in resolve state = resolution.resolve(requirements, max_rounds=max_rounds) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_vendor\resolvelib\resolvers.py", line 397, in resolve self._add_to_criteria(self.state.criteria, r, parent=None) File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_vendor\resolvelib\resolvers.py", line 173, in _add_to_criteria if not criterion.candidates: File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_vendor\resolvelib\structs.py", line 156, in bool return bool(self._sequence) ^^^^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\resolution\resolvelib\found_candidates.py", line 155, in bool return any(self) ^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\resolution\resolvelib\found_candidates.py", line 143, in return (c for c in iterator if id(c) not in self._incompatible_ids) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\resolution\resolvelib\found_candidates.py", line 47, in _iter_built candidate = func() ^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\resolution\resolvelib\factory.py", line 206, in _make_candidate_from_link self._link_candidate_cache[link] = LinkCandidate( ^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\resolution\resolvelib\candidates.py", line 293, in init super().init( File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\resolution\resolvelib\candidates.py", line 156, in init self.dist = self._prepare() ^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\resolution\resolvelib\candidates.py", line 225, in _prepare dist = self._prepare_distribution() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\resolution\resolvelib\candidates.py", line 304, in _prepare_distribution return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\operations\prepare.py", line 516, in prepare_linked_requirement return self._prepare_linked_requirement(req, parallel_builds) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\operations\prepare.py", line 587, in _prepare_linked_requirement local_file = unpack_url( ^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\operations\prepare.py", line 166, in unpack_url file = get_http_url( ^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\operations\prepare.py", line 107, in get_http_url from_path, content_type = download(link, temp_dir.path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\network\download.py", line 147, in call for chunk in chunks: File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\network\utils.py", line 63, in response_chunks for chunk in response.raw.stream( File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_vendor\urllib3\response.py", line 622, in stream data = self.read(amt=amt, decode_content=decode_content) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_vendor\urllib3\response.py", line 560, in read with self._error_catcher(): File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 155, in exit self.gen.throw(typ, value, traceback) File "C:\Users\HP\AppData\Local\Programs\Python\Python311\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.

[notice] A new release of pip is available: 23.1.2 -> 23.2.1 [notice] To update, run: python.exe -m pip install --upgrade pip PS C:\Users\HP\Desktop\个人\code\wop> ### python.exe -m pip install --upgrade pip Requirement already satisfied: pip in c:\users\hp\appdata\local\programs\python\python311\lib\site-packages (23.1.2) Collecting pip Downloading pip-23.2.1-py3-none-any.whl (2.1 MB) ━╸━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.1/2.1 MB 152.8 kB/s eta 0:00:14 ERROR: Exception: Traceback (most recent call last): File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_vendor\urllib3\response.py", line 438, in _error_catcher yield File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_vendor\urllib3\response.py", line 561, in read data = self._fp_read(amt) if not fp_closed else b"" ^^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_vendor\urllib3\response.py", line 527, in _fp_read return self._fp.read(amt) if amt is not None else self._fp.read() ^^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_vendor\cachecontrol\filewrapper.py", line 90, in read data = self.__fp.read(amt) ^^^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\http\client.py", line 466, in read s = self.fp.read(amt) ^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\socket.py", line 706, in readinto return self._sock.recv_into(b) ^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 1278, in recv_into return self.read(nbytes, buffer) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\ssl.py", line 1134, in read return self._sslobj.read(len, buffer) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TimeoutError: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\cli\base_command.py", line 169, in exc_logging_wrapper status = run_func(*args) ^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\cli\req_command.py", line 248, in wrapper return func(self, options, args) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\commands\install.py", line 377, in run requirement_set = resolver.resolve( ^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\resolution\resolvelib\resolver.py", line 92, in resolve result = self._result = resolver.resolve( ^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_vendor\resolvelib\resolvers.py", line 546, in resolve state = resolution.resolve(requirements, max_rounds=max_rounds) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_vendor\resolvelib\resolvers.py", line 397, in resolve self._add_to_criteria(self.state.criteria, r, parent=None) File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_vendor\resolvelib\resolvers.py", line 173, in _add_to_criteria if not criterion.candidates: File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_vendor\resolvelib\structs.py", line 156, in bool return bool(self._sequence) ^^^^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\resolution\resolvelib\found_candidates.py", line 155, in bool return any(self) ^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\resolution\resolvelib\found_candidates.py", line 143, in return (c for c in iterator if id(c) not in self._incompatible_ids) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\resolution\resolvelib\found_candidates.py", line 97, in _iter_built_with_inserted candidate = func() ^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\resolution\resolvelib\factory.py", line 206, in _make_candidate_from_link self._link_candidate_cache[link] = LinkCandidate( ^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\resolution\resolvelib\candidates.py", line 293, in init super().init( File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\resolution\resolvelib\candidates.py", line 156, in init self.dist = self._prepare() ^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\resolution\resolvelib\candidates.py", line 225, in _prepare dist = self._prepare_distribution() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\resolution\resolvelib\candidates.py", line 304, in _prepare_distribution return preparer.prepare_linked_requirement(self._ireq, parallel_builds=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\operations\prepare.py", line 516, in prepare_linked_requirement return self._prepare_linked_requirement(req, parallel_builds) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\operations\prepare.py", line 587, in _prepare_linked_requirement local_file = unpack_url( ^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\operations\prepare.py", line 166, in unpack_url file = get_http_url( ^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\operations\prepare.py", line 107, in get_http_url from_path, content_type = download(link, temp_dir.path) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\network\download.py", line 147, in call for chunk in chunks: File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\cli\progress_bars.py", line 53, in _rich_progress_bar for chunk in iterable: File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_internal\network\utils.py", line 63, in response_chunks for chunk in response.raw.stream( File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_vendor\urllib3\response.py", line 622, in stream data = self.read(amt=amt, decode_content=decode_content) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\site-packages\pip_vendor\urllib3\response.py", line 560, in read with self._error_catcher(): File "C:\Users\HP\AppData\Local\Programs\Python\Python311\Lib\contextlib.py", line 155, in exit self.gen.throw(typ, value, traceback) File "C:\Users\HP\AppData\Local\Programs\Python\Python311\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.

PS C:\Users\HP\Desktop\个人\code\wop> ### pip list Package Version


asttokens 2.4.0 backcall 0.2.0 colorama 0.4.6 comm 0.1.4 debugpy 1.8.0 decorator 5.1.1 executing 1.2.0 ipykernel 6.25.2 ipython 8.15.0 jedi 0.19.0 jupyter_client 8.3.1 jupyter_core 5.3.1 matplotlib-inline 0.1.6 nest-asyncio 1.5.8 packaging 23.1 parso 0.8.3 pickleshare 0.7.5 pip 23.1.2 platformdirs 3.10.0 prompt-toolkit 3.0.39 psutil 5.9.5 pure-eval 0.2.2 Pygments 2.16.1 python-dateutil 2.8.2 pywin32 306 pyzmq 25.1.1 setuptools 65.5.0 simpleeval 0.9.13 six 1.16.0 stack-data 0.6.2 tornado 6.3.3 traitlets 5.10.0 wcwidth 0.2.6

neolee commented 1 year ago

网络问题导致你安装 termcolor 这个包失败了,那么后续自然无法使用。

解决方案可以考虑换个国内的 PyPi 镜像,具体参见本站 Wiki 里的这个问答

murmurfish commented 1 year ago

已通过国内的 PyPi 镜像解决,谢谢!