Problem creating python virtual env on CentOS 7
NickName:nilesOien Ask DateTime:2022-02-08T02:59:40

Problem creating python virtual env on CentOS 7

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

More about “Problem creating python virtual env on CentOS 7” related questions

Problem creating python virtual env on CentOS 7

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/...

Show Detail

Install Python 3.7,PIP,virtual env on Centos7

Currenlty my linux machine has Centos7 and by deafault i got Python 2.7.5 and i have installed python 3.6.8.Now i want to install Python 3.7,pip,virtual env on to my machine. We tried below link,but

Show Detail

Python virtual environment is not activating in centOS

I am trying to install django in CentOS 7 cloud server. For that I have installed Virtual environment by using python -m venv env. And environment installed successfully, but it is not activating w...

Show Detail

Centos RPM with python virtual env

I am trying to deploy my python virtualenv as centos rpm. Following steps I have taken. Created virtual environment with required dependencies. One of requirement is pyOpenSSL Built rpm packag...

Show Detail

How to install active python in virtual environment on centos

How can i install ACtive python in virtual env. I have this problem as in this post answer https://stackoverflow.com/a/7458717/1958218 Now that was solved by using active python on centos itself....

Show Detail

Virtual Environment Setup Fails on CentOS7 With Python3.6

Following these directions: https://www.digitalocean.com/community/tutorials/how-to-install-python-3-and-set-up-a-local-programming-environment-on-centos-7 The following command: $ python3.6 -...

Show Detail

Problems creating virtual env with different Python version

I'm working on a big project that needs to be ported from python2.7 to python3.7. For developing, I rely on virtual envs. For the 2.7v, I'm using a virtual environment created with the virtualenv ...

Show Detail

python virtual env issue

While using command pipenv shell to create virtual env for project it shows below error: “Creating a virtualenv for this project... Pipfile: /opt/fiware-env/ckan/Pipfile Using /usr/bin/python3.5 (3...

Show Detail

Django virtual env issues with Python and Atom

I've been all over the site trying to find a solution for a problem i am running into with my virtual environment and the python version being used. I have installed mini conda I am on a Mac I have...

Show Detail

Centos 7, Python shell witch actived virtual envirometn dont recognize backspace instead put H^

Im using a centos 7 server, and runing Python 3.7.9 but the problem is that when i have the python's virtual enviroment activated, open the python shell, write anything and try to delete the caracter

Show Detail