大数据计算MaxCompute pip安装命令pip install -U imbalanced-learn报错:DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
WARNING: The directory '/root/.cache/pip' or its parent directory is not owned or is not writable by the current user. The cache has been disabled. Check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Defaulting to user installation because normal site-packages is not writeable
Collecting imbalanced-learn
Downloading imbalanced-learn-0.12.0.tar.gz (29.7 MB)
ERROR: Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/pip/_internal/cli/base_command.py", line 223, in _main
status = self.run(options, args)
File "/usr/lib/python2.7/site-packages/pip/_internal/cli/req_command.py", line 180, in wrapper
return func(self, options, args)
File "/usr/lib/python2.7/site-packages/pip/_internal/commands/install.py", line 321, in run
reqs, check_supported_wheels=not options.target_dir
File "/usr/lib/python2.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 180, in resolve
discovered_reqs.extend(self._resolve_one(requirement_set, req))
File "/usr/lib/python2.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 385, in _resolve_one
dist = self._get_dist_for(req_to_install)
File "/usr/lib/python2.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 337, in _get_dist_for
dist = self.preparer.prepare_linked_requirement(req)
File "/usr/lib/python2.7/site-packages/pip/_internal/operations/prepare.py", line 480, in prepare_linked_requirement
return self._prepare_linked_requirement(req, parallel_builds)
File "/usr/lib/python2.7/site-packages/pip/_internal/operations/prepare.py", line 505, in _prepare_linked_requirement
self.download_dir, hashes,
File "/usr/lib/python2.7/site-packages/pip/_internal/operations/prepare.py", line 257, in unpack_url
hashes=hashes,
File "/usr/lib/python2.7/site-packages/pip/_internal/operations/prepare.py", line 130, in get_http_url
from_path, content_type = download(link, temp_dir.path)
File "/usr/lib/python2.7/site-packages/pip/_internal/network/download.py", line 163, in call
for chunk in chunks:
File "/usr/lib/python2.7/site-packages/pip/_internal/cli/progress_bars.py", line 168, in iter
for x in it:
File "/usr/lib/python2.7/site-packages/pip/_internal/network/utils.py", line 88, in response_chunks
decode_content=False,
File "/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.py", line 576, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.py", line 541, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "/usr/lib64/python2.7/contextlib.py", line 35, in exit
self.gen.throw(type, value, traceback)
File "/usr/lib/python2.7/site-packages/pip/_vendor/urllib3/response.py", line 451, in _error_catcher
raise ReadTimeoutError(self._pool, None, "Read timed out.")
ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out. 是什么原因?
这个错误是因为在安装imbalanced-learn时,Python 2.7已经到达了生命周期的尽头,不再维护。同时,pip 21.0将放弃对Python 2.7的支持。此外,还出现了读取超时的错误。建议升级Python版本并使用支持ython 3的pip版本。
错误提示表明您正在使用已经不再维护的Python 2.7版本,并且在下载imbalanced-learn包时出现了超时错误。解决办法是升级到Python 3.x版本,并确保有足够的网络带宽和稳定的连接以完成包的下载安装。若环境受限无法升级Python版本,请尝试增加网络超时限制或者更换网络环境再次尝试安装。
此报错信息主要包括两个方面的问题:
Python 2.7 已停止维护:
报错提示指出,Python 2.7已在2020年1月1日结束生命周期,不再提供官方维护。从pip 21.0版本开始,已不再支持Python 2.7。因此,你需要升级到Python 3.x版本才能继续使用pip安装最新的库。
下载超时错误:
最终导致安装失败的具体错误是ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
,这意味着在尝试从Python官方仓库(pypi)下载imbalanced-learn
包时,网络连接超时。这可能是由于网络不稳定、服务器响应慢或者请求耗时过长等原因造成的。
要解决这个问题,请尝试以下措施:
升级Python版本:首先确保你的环境中使用的是Python 3.x版本。
重试下载:由于是网络问题,可以稍后重新尝试运行安装命令,有时候网络状况恢复后就能正常下载。
设置pip代理:如果你处在一个网络环境有限制或速度较慢的地方,可以考虑设置pip使用代理服务器下载,例如:
pip install --proxy http://user:password@proxy.server:port imbalanced-learn
增加超时时间:临时增加pip下载的超时时间:
pip install --default-timeout=120 imbalanced-learn
注意:以上示例中的代理服务器地址、端口、用户名和密码需替换为你实际可用的代理信息。
综上所述,建议首先升级到Python 3.x版本,并在稳定的网络环境下尝试安装所需的库。如果网络不稳定,可以尝试通过设置代理或者增加超时时间的方式来解决问题。
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
MaxCompute(原ODPS)是一项面向分析的大数据计算服务,它以Serverless架构提供快速、全托管的在线数据仓库服务,消除传统数据平台在资源扩展性和弹性方面的限制,最小化用户运维投入,使您经济并高效的分析处理海量数据。