python 创建虚拟环境时报错OSError, setuptools下载失败

错误信息如下:

Using base prefix ‘c:\\users\\huful\\appdata\\local\\programs\\python\\python36-32‘
New python executable in E:\Learning\Python\search\Scripts\python.exe
Installing setuptools, pip, wheel...
Complete output from command E:\Learning\Python\search\Scripts\python.exe - setuptools pip wheel:
Collecting setuptools
Using cached https://files.pythonhosted.org/packages/96/06/c8ee69628191285ddddffb277bd5abdf769166e7a14b867c2a172f0175b1/setuptools-40.4.3-py2.py3-none-any.whl
Collecting pip
Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Downloading https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl (1.3MB)
Exception:
Traceback (most recent call last):
File "c:\users\huful\appdata\local\programs\python\python36-32\lib\site-packages\virtualenv_support\pip-9.0.3-py2.py3-none-any.whl\pip\_vendor\urllib3\response.py", line 302, in _error_catcher
yield
File "c:\users\huful\appdata\local\programs\python\python36-32\lib\site-packages\virtualenv_support\pip-9.0.3-py2.py3-none-any.whl\pip\_vendor\urllib3\response.py", line 384, in read
data = self._fp.read(amt)
File "c:\users\huful\appdata\local\programs\python\python36-32\lib\site-packages\virtualenv_support\pip-9.0.3-py2.py3-none-any.whl\pip\_vendor\cachecontrol\filewrapper.py", line 60, in read
data = self.__fp.read(amt)
File "c:\users\huful\appdata\local\programs\python\python36-32\Lib\http\client.py", line 449, in read
n = self.readinto(b)
File "c:\users\huful\appdata\local\programs\python\python36-32\Lib\http\client.py", line 493, in readinto
n = self.fp.readinto(b)
File "c:\users\huful\appdata\local\programs\python\python36-32\Lib\socket.py", line 586, in readinto
return self._sock.recv_into(b)
File "c:\users\huful\appdata\local\programs\python\python36-32\Lib\ssl.py", line 1002, in recv_into
return self.read(nbytes, buffer)
File "c:\users\huful\appdata\local\programs\python\python36-32\Lib\ssl.py", line 865, in read
return self._sslobj.read(len, buffer)
File "c:\users\huful\appdata\local\programs\python\python36-32\Lib\ssl.py", line 625, 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\huful\appdata\local\programs\python\python36-32\lib\site-packages\virtualenv_support\pip-9.0.3-py2.py3-none-any.whl\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "c:\users\huful\appdata\local\programs\python\python36-32\lib\site-packages\virtualenv_support\pip-9.0.3-py2.py3-none-any.whl\pip\commands\install.py", line 324, in run
requirement_set.prepare_files(finder)
File "c:\users\huful\appdata\local\programs\python\python36-32\lib\site-packages\virtualenv_support\pip-9.0.3-py2.py3-none-any.whl\pip\req\req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "c:\users\huful\appdata\local\programs\python\python36-32\lib\site-packages\virtualenv_support\pip-9.0.3-py2.py3-none-any.whl\pip\req\req_set.py", line 620, in _prepare_file
session=self.session, hashes=hashes)
File "c:\users\huful\appdata\local\programs\python\python36-32\lib\site-packages\virtualenv_support\pip-9.0.3-py2.py3-none-any.whl\pip\download.py", line 821, in unpack_url
hashes=hashes
File "c:\users\huful\appdata\local\programs\python\python36-32\lib\site-packages\virtualenv_support\pip-9.0.3-py2.py3-none-any.whl\pip\download.py", line 659, in unpack_http_url
hashes)
File "c:\users\huful\appdata\local\programs\python\python36-32\lib\site-packages\virtualenv_support\pip-9.0.3-py2.py3-none-any.whl\pip\download.py", line 882, in _download_http_url
_download_url(resp, link, content_file, hashes)
File "c:\users\huful\appdata\local\programs\python\python36-32\lib\site-packages\virtualenv_support\pip-9.0.3-py2.py3-none-any.whl\pip\download.py", line 603, in _download_url
hashes.check_against_chunks(downloaded_chunks)
File "c:\users\huful\appdata\local\programs\python\python36-32\lib\site-packages\virtualenv_support\pip-9.0.3-py2.py3-none-any.whl\pip\utils\hashes.py", line 46, in check_against_chunks
for chunk in chunks:
File "c:\users\huful\appdata\local\programs\python\python36-32\lib\site-packages\virtualenv_support\pip-9.0.3-py2.py3-none-any.whl\pip\download.py", line 571, in written_chunks
for chunk in chunks:
File "c:\users\huful\appdata\local\programs\python\python36-32\lib\site-packages\virtualenv_support\pip-9.0.3-py2.py3-none-any.whl\pip\utils\ui.py", line 139, in iter
for x in it:
File "c:\users\huful\appdata\local\programs\python\python36-32\lib\site-packages\virtualenv_support\pip-9.0.3-py2.py3-none-any.whl\pip\download.py", line 560, in resp_read
decode_content=False):
File "c:\users\huful\appdata\local\programs\python\python36-32\lib\site-packages\virtualenv_support\pip-9.0.3-py2.py3-none-any.whl\pip\_vendor\urllib3\response.py", line 436, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "c:\users\huful\appdata\local\programs\python\python36-32\lib\site-packages\virtualenv_support\pip-9.0.3-py2.py3-none-any.whl\pip\_vendor\urllib3\response.py", line 401, in read
raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
File "c:\users\huful\appdata\local\programs\python\python36-32\Lib\contextlib.py", line 100, in __exit__
self.gen.throw(type, value, traceback)
File "c:\users\huful\appdata\local\programs\python\python36-32\lib\site-packages\virtualenv_support\pip-9.0.3-py2.py3-none-any.whl\pip\_vendor\urllib3\response.py", line 307, 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.
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
File "c:\users\huful\appdata\local\programs\python\python36-32\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\huful\appdata\local\programs\python\python36-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\huful\AppData\Local\Programs\Python\Python36-32\Scripts\virtualenv.exe\__main__.py", line 9, in <module>
File "c:\users\huful\appdata\local\programs\python\python36-32\lib\site-packages\virtualenv.py", line 712, in main
symlink=options.symlink)
File "c:\users\huful\appdata\local\programs\python\python36-32\lib\site-packages\virtualenv.py", line 953, in create_environment
download=download,
File "c:\users\huful\appdata\local\programs\python\python36-32\lib\site-packages\virtualenv.py", line 904, in install_wheel
call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
File "c:\users\huful\appdata\local\programs\python\python36-32\lib\site-packages\virtualenv.py", line 796, in call_subprocess
% (cmd_desc, proc.returncode))
OSError: Command E:\Learning\Python\search\Scripts\python.exe - setuptools pip wheel failed with error code 2

总结错误信息内容,是在 Downloading https://files.pythonhosted.org/packages/c2/d7/90f34cb0d83a6c5631cf71dfe64cc1054598c843a92b400e55675cc2ac37/pip-18.1-py2.py3-none-any.whl (1.3MB)之时报的错,表达的意思大致是模块下载太慢导致的网络问题,试了很多次仍然无法创建虚拟环境。
网上有的博客说可能是中文路径、pip需要升级、python安装路径中有空格等,都没能解决问题。

最后使用 virtualenv myenv --no-setuptools 成功创建虚拟环境,创建虚拟环境后又在虚拟环境下使用 pip install setuptools命令给虚拟环境装上setuptools.

可是下载模块的时候明明是pip下载失败,我不安装setuptools反而创建虚拟环境成功,并且立马再创建其他的虚拟环境也能成功,这其中究竟是什么原理就不清楚了。

原文地址:https://www.cnblogs.com/hufulinblog/p/9824579.html

时间: 2024-10-06 02:44:29

python 创建虚拟环境时报错OSError, setuptools下载失败的相关文章

Python创建文件报错OSError:[Errno 22] Invalid argument处理

问题: windows平台下使用python open函数w模式打开文件报错"OSError: [Errno 22] Invalid argument: '../news/"消费升维"成零售业新风口?渠道多元同步跟进.txt'" 解决: 本来猜测是转义符的问题,但是使用python原字符串仍然不能解决问题. 后来发现其实是windows下文件的命名存在限制: 在Windows系统中,文件名不允许使用的字符有: < > / \ | : " * ?

python 读取文件时报错UnicodeDecodeError: &#39;gbk&#39; codec can&#39;t decode byte 0x80 in position 205: illegal multibyte sequence

python读写txt文件转化成excel文件 python读取文件时提示"UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 205: illegal multibyte sequence" 解决办法1. FILE_OBJECT= open('order.log','r', encoding='UTF-8') 解决办法2. FILE_OBJECT= open('order.log','rb') pyth

QL Server 创建用户时报错:15023 用户,组或角色&#39;XXX&#39;在当前数据库中已存在?

在使用SQL Server 2000时,我们经常会遇到一个情况:需要把一台服务器上的数据库转移到另外一台服务器上.而转移完成后,需要给一个"登录"关联一个"用户"时,往往会发生错误: “错误15023:当前数据库中已存在用户或角色” 这个问题非常棘手,几经排常找到了原因与解决方法,因为这个问题与解决方法均比较复杂,所以把这个过程中的一些经验纪录下来与大家分享,希望能对大家以后的类似操作有所帮助. 原因及解决办法如下: 首先介绍一下sql server中“登录”与“用

在执行inoic创建项目时报错

在执行inoic创建项目时报错.主要错误是:operation not permitted, scandir 1 × Running command - failed! 2 [ERROR] npm ERR! path C:\Users\Administrator\cutePuppyPics\node_modules\fsevents\node_modules\dashdash\node_modul 3 4 npm ERR! code EPERM 5 npm ERR! errno -4048 6

python 脚本运行时报错: AttributeError: &#39;module&#39; object has no attribute ***

最近在编写Python脚本过程中遇到一个问题比较奇怪:Python脚本完全正常没问题,但执行总报错"AttributeError: 'module' object has no attribute 'xxx'".这其实是.pyc文件存在问题. 问题定位: 查看import库的源文件,发现源文件存在且没有错误,同时存在源文件的.pyc文件 问题解决方法: 1. 命名py脚本时,不要与python预留字,模块名等相同 2. 删除该库的.pyc文件(因为py脚本每次运行时均会生成.pyc文件

python 读取文件时报错: UnicodeDecodeError: &#39;gbk&#39; codec can&#39;t decode byte 0xa4 in position 127: illegal multibyte sequence

UnicodeDecodeError: 'gbk' codec can't decode byte 0xa4 in position 127: illegal multibyte sequence python读取文件时提示UnicodeDecodeError: 'gbk' codec can't decode byte 0xa4 in position 127: illegal multibyte sequence 解决办法: FILE_OBJECT= open('order.log','r'

python 创建虚拟环境遇到的问题

mkvirtualenv django_env -p python3 会遇到一些问题, 1.首先需要安装 1.升级python包管理工具pip pip install --upgrade pip 备注:当你想升级一个包的时候 `pip install --upgrade 包名` 2.python虚拟环境安装 sudo apt-get install python-virtualenv sudo easy_install virtualenvwrapper 命令输入:mkvirtualenv 报错

关于vs 打开网站时报错 配置iis express失败 无法访问IIS元数据库...

我安装了vs2015,一开始创建项目,网站都没问题,有一次突然打开项目时报错,瞬间懵逼,我啥都没干啊!!! 网上找了很多内容,基本上没用. 最后找到一种方法,注册表,最终解决了,由于本人电脑就两盘C.H   注册表路径设置了D盘... 进入windows\regedit.exe下的HKEY_CRRENT_USER\Software\Microsoft\Windows\CurrentVersion\Exploer\User Shell Folders 修改Personal 相对应的value为 %

新的云主机 python 创建虚拟环境

1.为什么要搭建虚拟环境? 问题:如果在一台电脑上, 想开发多个不同的项目, 需要用到同一个包的不同版本, 如果使用上面的命令, 在同一个目录下安装或者更新, 新版本会覆盖以前的版本, 其它的项目就无法运行了.解决方案 : 虚拟环境 作用 : 虚拟环境可以搭建独立的python运行环境, 使得单个项目的运行环境与其它项目互不影响. 在开发过程中, 便于控制python的web框架或工具包的版本,创建多个虚拟环境,就相当于我们在一台电脑上拥有了多个python解释器. 好了,接下来我们开始安装了~