实用的知识教程
汇智娱乐万赢棋牌游戏大全 > 网络知识 >  正文

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

2020-01-11 11:00:52 来源: 汇智娱乐万赢棋牌游戏大全 记者 汇智娱乐万赢棋牌游戏大全

[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]# wgethttps://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安装



温馨提示如有转载或引用以上内容之必要,敬请将作为出处标注,谢谢合作!

相关新闻
凡注有"汇智娱乐万赢棋牌游戏大全"的稿件,均为汇智娱乐万赢棋牌游戏大全独家版权所有,未经许可不得转载或镜像;授权转载必须注明来源为"汇智娱乐万赢棋牌游戏大全",并保留"汇智娱乐万赢棋牌游戏大全"。
博评网