Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

creating venv with python3.9 causes error

I'm relatively new with Python and I have been creating virtual environments for my different projects. If I use the following command:

python3 -m venv <name_of_env> 

this works and creates a virtual environment with python 3.8.5

However if I try the same command using -> python3.9 -m venv <name_of_env> it returns an error Error: Command '['/home/andrew/coding/pythonCourse/test_folder/tested_works/bin/testing_fails/bin/python3.9', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.

after this error it does create the folder but the bin file does not have the activate file and I cannot activate it.

Is the above method not suitable for python 3.9?. Using Conda I have no problems creating virtual environments with 3.9.

Thank you in advance for any advice.

like image 435
Andrew Reynolds Avatar asked Mar 30 '26 23:03

Andrew Reynolds


1 Answers

You must install Python 3.9 venv:

sudo apt install python3.9-venv

Then just do

python3.9 -m venv .venv
.venv/bin/python --version
like image 136
Jonas Lima Avatar answered Apr 02 '26 13:04

Jonas Lima



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!