pyvenv returns non-zero exit status 1 (during the installation of pip stage)
Solution 1
Here's an approach that is fairly O/S agnostic...
Both the pyvenv
and python
commands themselves include a --without-pip
option that enable you to work around this issue; without resorting to setuptool
or other headaches. Taking note of my inline comments
below, here's how to do it, and is very easy to understand:
user$ pyvenv --without-pip ./pyvenv.d # Create virtual environment this way;
user$ python -m venv --without-pip ./pyvenv.d # --OR-- this newer way. Both work.
user$ source ./pyvenv.d/bin/activate # Now activate this new virtual environment.
(pyvenv.d) user$
# Within it, invoke this well-known script to manually install pip(1) into /pyvenv.d:
(pyvenv.d) user$ curl https://bootstrap.pypa.io/get-pip.py | python
(pyvenv.d) user$ deactivate # Next, reactivate this virtual environment,
user$ source ./pyvenv.d/bin/activate # which will now include the pip(1) command.
(pyvenv.d) user$
(pyvenv.d) user$ which pip # Verify that pip(1) is indeed present.
/path/to/pyvenv.d/bin/pip
(pyvenv.d) user$ pip install --upgrade pip # And finally, upgrade pip(1) itself;
(pyvenv.d) user$ # although it will likely be the
# latest version already.
# And that's it!
I hope this helps. \(◠﹏◠)/
Solution 2
2020, on python3.8 on WSL2 (Ubuntu) the following solved this for me:
sudo apt install python3.8-venv
Related videos on Youtube
NYCeyes
RESUME/CV: https://jupyter.ai Work Areas: Both director and hands-on implement data processing, data analytics and backend services in Python-3, Spark 2.0, Kafka, NoSQL genres, Microservices, and related glue technologies. AMAZON WEB SERVICES (AWS) • LINUX / LXC CONTAINERS • DOCKER • PYTHON 3 • UNIX BASH & CLI AWS-based HYBRID DATACENTER ARCHITECTURES • AWS-based DATACENTER MIGRATIONS AWS-based BUSINESS CONTINUITY & DISASTER RECOVERY (BC/DR) • CLOUDERA CDH and HADOOP ECOSYSTEM AWS-based REALTIME STREAM COMPLEX EVENT PROCESSORS (C.E.P.) • E.T.L. • NoSQL DATABASES LONG DISTANCE MULTI-SITE FIBRE-CHANNEL SAN ARCHITECTURES FOR BC/DR AWS TOOLS (abbrev): SQS | ECS | SNS | DYNAMODB | ELASTICACHE | EC2 | VPC | KINESIS | DIRECT CONNECT | (Etc). OPEN SOURCE TOOLS (abbrev): MONGODB | C* | REDIS | STORM | KAFKA | SPARK | SCIKIT-LEARN | TENSORFLOW | (Etc).
Updated on September 15, 2022Comments
-
NYCeyes about 1 year
If you should ever encounter the following error when creating a
Python
virtual environment using thepyvenv
command:user$ pyvenv my_venv_dir Error: Command '['/home/user/my_venv_dir/bin/python', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1
... then the answer (below) provides a simple way to work around it, without resorting to
setuptools
and it's related acrobatics. -
feedy about 2 yearsA bit late to the party, but thank you so much! This has completely fixed my venv issues!
-
José Castillo over 1 year...and python3.9 works too