安装虚拟环境报错:OSError:Command ... - setuptools pkg_resources pip

本文解决了一个在更新虚拟环境中pip时遇到的错误,详细步骤包括避免使用sudo命令直接更新pip,确保在虚拟环境中进行操作。通过正确的方法,可以顺利更新pip并创建及进入虚拟环境。

安装虚拟环境是报错:

OSError: Command /home/python/.virtua…iduosite/bin/python3 - setuptools pkg_resources pip wheel failed with error code 2

在这里插入图片描述
解决方案:

依次输入下面两条命令,更新pip

pip3 -V
pip3 install --upgrade pip		# 注意不能加sudo,如果加了sudo说明是在主机操作,不是在虚拟环境升级pip了。

更新完后再重新输入命令,安装虚拟环境即可,后续可以

mkvirtualenv django_meiduosite -p python3	# 创建虚拟环境并进入
pip install django==1.11.11				# 在虚拟环境,安装Django。
yangs@yangs:~$ virtualenv ~/venv/hrlnav --python=python3.6 Running virtualenv with interpreter /usr/bin/python3.6 Using base prefix '/usr' New python executable in /home/yangs/venv/hrlnav/bin/python3.6 Also creating executable in /home/yangs/venv/hrlnav/bin/python Installing setuptools, pkg_resources, pip, wheel... Complete output from command /home/yangs/venv/hrlnav/bin/python3.6 - setuptools pkg_resources pip wheel: Collecting setuptools Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.python.org', port=443): Read timed out. (read timeout=15)",)': /simple/setuptools/ Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out. (read timeout=15)",)': /packages/b0/3a/88b210db68e56854d0bcf4b38e165e03be377e13907746f825790f3df5bf/setuptools-59.6.0-py3-none-any.whl Downloading https://files.pythonhosted.org/packages/b0/3a/88b210db68e56854d0bcf4b38e165e03be377e13907746f825790f3df5bf/setuptools-59.6.0-py3-none-any.whl (952kB) Exception: Traceback (most recent call last): File "/home/yangs/venv/hrlnav/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/response.py", line 302, in _error_catcher yield File "/home/yangs/venv/hrlnav/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/response.py", line 384, in read data = self._fp.read(amt) File "/home/yangs/venv/hrlnav/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/filewrapper.py", line 60, in read data = self.__fp.read(amt) File "/usr/lib/python3.6/http/client.py", line 467, in read n = self.readinto(b) File "/usr/lib/python3.6/http/client.py", line 511, in readinto n = self.fp.readinto(b) File "/usr/lib/python3.6/socket.py", line 586, in readinto return self._sock.recv_into(b) File "/usr/lib/python3.6/ssl.py", line 1012, in recv_into return self.read(nbytes, buffer) File "/usr/lib/python3.6/ssl.py", line 874, in read return self._sslobj.read(len, buffer) File "/usr/lib/python3.6/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 "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/basecommand.py", line 215, in main status = self.run(options, args) File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/commands/install.py", line 353, in run wb.build(autobuilding=True) File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/wheel.py", line 749, in build self.requirement_set.prepare_files(self.finder) File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/req/req_set.py", line 380, in prepare_files ignore_dependencies=self.ignore_dependencies)) File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/req/req_set.py", line 620, in _prepare_file session=self.session, hashes=hashes) File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/download.py", line 821, in unpack_url hashes=hashes File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/download.py", line 659, in unpack_http_url hashes) File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/download.py", line 902, in _download_http_url _download_url(resp, link, content_file, hashes) File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/download.py", line 603, in _download_url hashes.check_against_chunks(downloaded_chunks) File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/utils/hashes.py", line 46, in check_against_chunks for chunk in chunks: File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/download.py", line 571, in written_chunks for chunk in chunks: File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/utils/ui.py", line 139, in iter for x in it: File "/usr/share/python-wheels/pip-9.0.1-py2.py3-none-any.whl/pip/download.py", line 560, in resp_read decode_content=False): File "/home/yangs/venv/hrlnav/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/response.py", line 436, in stream data = self.read(amt=amt, decode_content=decode_content) File "/home/yangs/venv/hrlnav/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/response.py", line 401, in read raise IncompleteRead(self._fp_bytes_read, self.length_remaining) File "/usr/lib/python3.6/contextlib.py", line 99, in __exit__ self.gen.throw(type, value, traceback) File "/home/yangs/venv/hrlnav/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/response.py", line 307, in _error_catcher raise ReadTimeoutError(self._pool, None, 'Read timed out.') urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out. ---------------------------------------- ...Installing setuptools, pkg_resources, pip, wheel...done. Traceback (most recent call last): File "/usr/lib/python3/dist-packages/virtualenv.py", line 2375, in <module> main() File "/usr/lib/python3/dist-packages/virtualenv.py", line 724, in main symlink=options.symlink) File "/usr/lib/python3/dist-packages/virtualenv.py", line 992, in create_environment download=download, File "/usr/lib/python3/dist-packages/virtualenv.py", line 922, in install_wheel call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT) File "/usr/lib/python3/dist-packages/virtualenv.py", line 817, in call_subprocess % (cmd_desc, proc.returncode)) OSError: Command /home/yangs/venv/hrlnav/bin/python3.6 - setuptools pkg_resources pip wheel failed with error code 2 这是什么错误
最新发布
05-14
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值