python创建虚拟环境报错_(OSError: Command /opt/venv2/bin/python3 - setuptools pip wheel failed with error cod...

富凯旋
2023-12-01

创建虚拟环境命令:virtualenv --no-sit-packages --python=python3 venv1

报错:

Running virtualenv with interpreter /usr/local/python3/bin/python3

Using base prefix ‘/usr/local/python3‘

New python executable in /opt/venv2/bin/python3

Also creating executable in /opt/venv2/bin/python

Installing setuptools, pip, wheel...

Complete output from command /opt/venv2/bin/python3 - setuptools pip wheel:

Looking in links: /usr/local/python3/lib/python3.6/site-packages/virtualenv_support

Collecting 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/ec/51/f45cea425fd5cb0b0380f5b0f048ebc1da5b417e48d304838c02d6288a1e/setuptools-41.0.1-py2.py3-none-any.whl

Downloading https://files.pythonhosted.org/packages/ec/51/f45cea425fd5cb0b0380f5b0f048ebc1da5b417e48d304838c02d6288a1e/setuptools-41.0.1-py2.py3-none-any.whl (575kB)

Exception:

Traceback (most recent call last):

File "/usr/local/python3/lib/python3.6/site-packages/virtualenv_support/pip-19.0.3-py2.py3-none-any.whl/pip/_vendor/urllib3/response.py", line 360, in _error_catcher

yield

File "/usr/local/python3/lib/python3.6/site-packages/virtualenv_support/pip-19.0.3-py2.py3-none-any.whl/pip/_vendor/urllib3/response.py", line 442, in read

data = self._fp.read(amt)

File "/usr/local/python3/lib/python3.6/site-packages/virtualenv_support/pip-19.0.3-py2.py3-none-any.whl/pip/_vendor/cachecontrol/filewrapper.py", line 62, in read

data = self.__fp.read(amt)

File "/usr/local/python3/lib/python3.6/http/client.py", line 449, in read

n = self.readinto(b)

File "/usr/local/python3/lib/python3.6/http/client.py", line 493, in readinto

n = self.fp.readinto(b)

File "/usr/local/python3/lib/python3.6/socket.py", line 586, in readinto

return self._sock.recv_into(b)

File "/usr/local/python3/lib/python3.6/ssl.py", line 1009, in recv_into

return self.read(nbytes, buffer)

File "/usr/local/python3/lib/python3.6/ssl.py", line 871, in read

return self._sslobj.read(len, buffer)

File "/usr/local/python3/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/local/python3/lib/python3.6/site-packages/virtualenv_support/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/cli/base_command.py", line 179, in main

status = self.run(options, args)

File "/usr/local/python3/lib/python3.6/site-packages/virtualenv_support/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/commands/install.py", line 315, in run

resolver.resolve(requirement_set)

File "/usr/local/python3/lib/python3.6/site-packages/virtualenv_support/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/resolve.py", line 131, in resolve

self._resolve_one(requirement_set, req)

File "/usr/local/python3/lib/python3.6/site-packages/virtualenv_support/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/resolve.py", line 294, in _resolve_one

abstract_dist = self._get_abstract_dist_for(req_to_install)

File "/usr/local/python3/lib/python3.6/site-packages/virtualenv_support/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/resolve.py", line 242, in _get_abstract_dist_for

self.require_hashes

File "/usr/local/python3/lib/python3.6/site-packages/virtualenv_support/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/operations/prepare.py", line 334, in prepare_linked_requirement

progress_bar=self.progress_bar

File "/usr/local/python3/lib/python3.6/site-packages/virtualenv_support/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/download.py", line 878, in unpack_url

progress_bar=progress_bar

File "/usr/local/python3/lib/python3.6/site-packages/virtualenv_support/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/download.py", line 702, in unpack_http_url

progress_bar)

File "/usr/local/python3/lib/python3.6/site-packages/virtualenv_support/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/download.py", line 946, in _download_http_url

_download_url(resp, link, content_file, hashes, progress_bar)

File "/usr/local/python3/lib/python3.6/site-packages/virtualenv_support/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/download.py", line 639, in _download_url

hashes.check_against_chunks(downloaded_chunks)

File "/usr/local/python3/lib/python3.6/site-packages/virtualenv_support/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/utils/hashes.py", line 62, in check_against_chunks

for chunk in chunks:

File "/usr/local/python3/lib/python3.6/site-packages/virtualenv_support/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/download.py", line 607, in written_chunks

for chunk in chunks:

File "/usr/local/python3/lib/python3.6/site-packages/virtualenv_support/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/utils/ui.py", line 159, in iter

for x in it:

File "/usr/local/python3/lib/python3.6/site-packages/virtualenv_support/pip-19.0.3-py2.py3-none-any.whl/pip/_internal/download.py", line 596, in resp_read

decode_content=False):

File "/usr/local/python3/lib/python3.6/site-packages/virtualenv_support/pip-19.0.3-py2.py3-none-any.whl/pip/_vendor/urllib3/response.py", line 494, in stream

data = self.read(amt=amt, decode_content=decode_content)

File "/usr/local/python3/lib/python3.6/site-packages/virtualenv_support/pip-19.0.3-py2.py3-none-any.whl/pip/_vendor/urllib3/response.py", line 459, in read

raise IncompleteRead(self._fp_bytes_read, self.length_remaining)

File "/usr/local/python3/lib/python3.6/contextlib.py", line 99, in __exit__

self.gen.throw(type, value, traceback)

File "/usr/local/python3/lib/python3.6/site-packages/virtualenv_support/pip-19.0.3-py2.py3-none-any.whl/pip/_vendor/urllib3/response.py", line 365, 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 "/usr/local/python3/lib/python3.6/site-packages/virtualenv.py", line 2567, in

main()

File "/usr/local/python3/lib/python3.6/site-packages/virtualenv.py", line 793, in main

symlink=options.symlink,

File "/usr/local/python3/lib/python3.6/site-packages/virtualenv.py", line 1088, in create_environment

install_wheel(to_install, py_executable, search_dirs, download=download)

File "/usr/local/python3/lib/python3.6/site-packages/virtualenv.py", line 935, in install_wheel

_install_wheel_with_search_dir(download, project_names, py_executable, search_dirs)

File "/usr/local/python3/lib/python3.6/site-packages/virtualenv.py", line 1025, in _install_wheel_with_search_dir

call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=script)

File "/usr/local/python3/lib/python3.6/site-packages/virtualenv.py", line 886, in call_subprocess

raise OSError("Command {} failed with error code {}".format(cmd_desc, proc.returncode))

OSError: Command /opt/venv2/bin/python3 - setuptools pip wheel failed with error code 2

原因:可能同时在多个服务器上创建

解决:在一个服务器上创建,在执行一遍命令

virtualenv --no-sit-packages --python=python3 venv1

 类似资料: