I'm on CentOS 7 :
$ cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
I am having trouble setting up a virtual env :
$ python3 -m venv /home/noien/myVenv
Error: Command '['/home/noien/myVenv/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.
It looks like there's a problem with ensurepip :
$ python3 -m ensurepip
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'
Looking for that file, not only is the file not there, but the path stops at /usr/lib64/python3.6/ensurepip/
- there is no /usr/lib64/python3.6/ensurepip/_bundled
What's REALLY confusing is that I have another CentOS machine on the same release, everything on both machines is up to date, the other machine also has no _bundled
subdirectory, and everything on the other machine works.
I've tried :
yum reinstall python3-pip
yum reinstall python3
yum reinstall setuptools
yum reinstall python36-devel
yum reinstall python36-setuptools
yum reinstall python36-virtualenv
yum reinstall python36-virtualenv
python3.6 -m pip install --upgrade pip
Looking in /usr/lib64/python3.6/ensurepip/__init__.py
I see, among other things :
_SETUPTOOLS_VERSION = "40.6.2"
_PIP_VERSION = "9.0.3"
I've tried adjusting the versions there to match what I have, which I get with pip3 -V
but no luck. Maybe that's not the right way to get the version?
Anyone have any ideas? It's confusing that I can make a virtual env on the other machine, and I can't see much difference between the two machines.
Copyright Notice:Content Author:「nilesOien」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/71023972/problem-creating-python-virtual-env-on-centos-7