Creating Virtual Environment with Python 3.11 Returns an Error
Asked Answered
S

3

12

I got an error when creating virtualenv with Python 3.11 interpreter.

I typed this in my terminal

python3.11 -m venv env

It returned this:

Error: Command '['/home/bambang/env/bin/python3.11', '-m', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.

What's possibly missing?

Smukler answered 3/2, 2023 at 16:11 Comment(0)
S
3

I tried to add --without-pip flag. It doesn't return an error so far

Smukler answered 4/2, 2023 at 15:8 Comment(3)
To complete the story, one usually do want 'pip'. So, look at the next step for example here: https://mcmap.net/q/102684/-pip-is-not-working-for-python-3-10-on-ubuntuEasternmost
I have fixed it, brother. I manually download pip afterwards, and install it. I have written full article to solve this my way, medium.com/@bambang.wirojoyo/…Smukler
pip will be missing when you want to install dependencies later, so this is kind of a very temporary workaround.Tourniquet
S
19
sudo apt install python3.11-venv
Spanjian answered 27/6, 2023 at 7:1 Comment(2)
On ubuntu 24.04, this fails with E: Package 'python3.11-venv' has no installation candidateLadykiller
Aha, it works if I do this first: sudo add-apt-repository ppa:deadsnakes/ppaLadykiller
S
3

I tried to add --without-pip flag. It doesn't return an error so far

Smukler answered 4/2, 2023 at 15:8 Comment(3)
To complete the story, one usually do want 'pip'. So, look at the next step for example here: https://mcmap.net/q/102684/-pip-is-not-working-for-python-3-10-on-ubuntuEasternmost
I have fixed it, brother. I manually download pip afterwards, and install it. I have written full article to solve this my way, medium.com/@bambang.wirojoyo/…Smukler
pip will be missing when you want to install dependencies later, so this is kind of a very temporary workaround.Tourniquet
P
-1

The best way to solve this is with "sudo".
I had multiple version of WSL ubuntu downloaded on my machine. I was having issues creating a virtual environment in Python 3.12 with python3.12 -m venv env even though I can creat a virtual environment in other ubuntu envrionemts.

The issue resolves it self if you do the following

sudo python3.11 -m venv env

This works for me so I hope it helps you guys

Penner answered 30/4 at 17:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.