<返回更多

centos8使用python3自带的venv创建虚拟环境报错问题

2019-12-19    
加入收藏

一,背景

[damon@localhost ~]$ Python3 -m venv pdf_env

Error: Command '['/home/damon/pdf_env/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.

 

一,解决方法1

[damon@localhost ~]$ python3 -m venv --with-pip pdf_env

[damon@localhost ~]$ source pdf_env/bin/activate

[damon@localhost ~]$curl https://bootstrap.pypa.io/get-pip.py | python

 

二,解决办法2

https://docs.python.org/3.4/library/ensurepip.html

[root@localhost ~]# python3 -m ensurepip --upgrade

Traceback (most recent call last):

File "/usr/lib64/python3.6/runpy.py", line 193, in _run_module_as_main

"__main__", mod_spec)

File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code

exec(code, run_globals)

File "/usr/lib64/python3.6/ensurepip/__main__.py", line 5, in <module>

sys.exit(ensurepip._main())

File "/usr/lib64/python3.6/ensurepip/__init__.py", line 232, in _main

default_pip=args.default_pip,

File "/usr/lib64/python3.6/ensurepip/__init__.py", line 129, in _bootstrap

shutil.copy(whl, tmpdir)

File "/usr/lib64/python3.6/shutil.py", line 245, in copy

copyfile(src, dst, follow_symlinks=follow_symlinks)

File "/usr/lib64/python3.6/shutil.py", line 120, in copyfile

with open(src, 'rb') as fsrc:

FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib64/python3.6/ensurepip/_bundled/setuptools-40.6.2-py2.py3-none-any.whl'

 

[root@localhost ~]# cd /usr/lib64/python3.6/ensurepip/

[root@localhost ensurepip]# ls

__init__.py __main__.py __pycache__ rewheel _uninstall.py

[root@localhost ensurepip]# mkdir _bundled

[root@localhost ensurepip]# cd _bundled

 

[root@localhost _bundled]# wget https://files.pythonhosted.org/packages/e7/16/da8cb8046149d50940c6110310983abb359bbb8cbc3539e6bef95c29428a/setuptools-40.6.2-py2.py3-none-any.whl

 

[root@localhost _bundled]# python3 -m ensurepip --upgrade

Traceback (most recent call last):

File "/usr/lib64/python3.6/runpy.py", line 193, in _run_module_as_main

"__main__", mod_spec)

File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code

exec(code, run_globals)

File "/usr/lib64/python3.6/ensurepip/__main__.py", line 5, in <module>

sys.exit(ensurepip._main())

File "/usr/lib64/python3.6/ensurepip/__init__.py", line 232, in _main

default_pip=args.default_pip,

File "/usr/lib64/python3.6/ensurepip/__init__.py", line 129, in _bootstrap

shutil.copy(whl, tmpdir)

File "/usr/lib64/python3.6/shutil.py", line 245, in copy

copyfile(src, dst, follow_symlinks=follow_symlinks)

File "/usr/lib64/python3.6/shutil.py", line 120, in copyfile

with open(src, 'rb') as fsrc:

FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib64/python3.6/ensurepip/_bundled/pip-9.0.3-py2.py3-none-any.whl'

[hpoi@hpoi02 ~]$ wget https://files.pythonhosted.org/packages/ac/95/a05b56bb975efa78d3557efa36acaf9cf5d2fd0ee0062060493687432e03/pip-9.0.3-py2.py3-none-any.whl

 

[root@localhost _bundled]# ls

pip-9.0.3-py2.py3-none-any.whl setuptools-40.6.2-py2.py3-none-any.whl

[root@localhost _bundled]# python3 -m ensurepip --upgrade

Collecting setuptools

Requirement already up-to-date: pip in /usr/local/lib/python3.6/site-packages

 

完全解决

[root@localhost _bundled]# cd

[root@localhost ~]# python3 -m venv pdf_env

 

四,总结pip版本太高了导致的,pip直接使用python3 get_pip.py安装

声明:本站部分内容来自互联网,如有版权侵犯或其他问题请与我们联系,我们将立即删除或处理。
▍相关推荐
更多资讯 >>>