Python virtual environment creation (python -m venv venv) fails

Hi,
This is more of a tidbits post than a support question. I don’t know where else to post it.

In OMLx, trying to create a python virtual environment (python -m venv venv) results in error saying,

Command '['/home/sv/sandbox/py-venv/bin/python3', '-m', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1

A solution is provided here. However, that would be using an alternate method to workaround than to fix the issue. The first thing that shows up on websearch to create python virtual environment is the command posted above. Some suggestion was to install python3-venv package but it is not available in OMLx. Turns out, the solution is simple: we have to ensure the ensurepip package is installed. :slight_smile:

ensurepip is one of the arguments passed (internally, as can be seen from the error message) and looking for ‘pip’ package,
I saw the package python-ensurepip.

sudo dnf install python-ensurepip

and we are good to go with, python -m venv venv.

What is the likelihood that every single Python scripter is going to use this?

I don’t know. Probably that’s why it is not a dependency.

It is generally recommended to use venv when coding in python, though.

1 Like