Cannot properly create a virtual enviroment in Python 3.12
Asked Answered
A

3

10

I use the command line

python3 -m venv .venv 

and a new .venv module is created but an error appears:

Error: Command '['/home/achu/Documentos/portfolio2023/.venv/bin/python3', '-m', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1

the bin directory doesn't contain the activate file.

I've tried

$ apt install python3.12-dev python3.12-venv
Angadresma answered 4/10, 2023 at 13:58 Comment(7)
error appears when you do what?Valerievalerio
Try other answers from #24123650Favour
@Valerievalerio when command is executedFavour
try same command with sudo?Valerievalerio
@Valerievalerio Don't use sudo unless it's for sysadmin tasks. Never set up a dev environment as root; don't work as root. A bad command can destroy your system.Balenciaga
python3 -m venv .venv works as expected with Python 3.12 on macOS 14.0. The activate script is created as expectedSquires
@Balenciaga I am asking for diagnostic purposes. It was not a tip or a solution.Valerievalerio
D
21

This worked for me:

sudo apt install python3.12-venv

and then

python3.12 -m venv new_venv

Doubler answered 24/10, 2023 at 13:16 Comment(0)
L
2

Check if pip installed. Check if you using python3.12, and not other versions of python3.

curl -sSL https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3.12 get-pip.py
Lozier answered 4/10, 2023 at 14:44 Comment(1)
pip is installed and when I check with python3 --version am using python3.12 but I also have python3.10 installed in usr/binAngadresma
T
0

Assuming Debian testing or derivatives, you can also try:

sudo aptitude -t testing install python3-pip-whl

This will upgrade the package providing pip, on my setup I got the same error as above due to an too old version of pip was installed.

Telium answered 8/11, 2023 at 8:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.