Python 3.8: No 'activate' command in venv

When I attempted to use Python’s venv module with a compiled version of Python 3.8.1 in a user’s home directory, the following error was produced:

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

A directory test_env was created, however, it was incomplete:

test_env/
├── bin
│   ├── python -> python3
│   └── python3 -> /home/a_user/python3.8/bin/python3
├── include
├── lib
│   └── python3.8
│       └── site-packages
├── lib64 -> lib
└── pyvenv.cfg

6 directories, 3 files

The ensurepip module was found to be installed:

python3 -m ensurepip
Looking in links: /tmp/tmpeqrn78f5
Requirement already satisfied: setuptools in ./python3.8/lib/python3.8/site-packages (41.2.0)
Requirement already satisfied: pip in ./python3.8/lib/python3.8/site-packages (19.2.3)

The issue is not clear and further troubleshooting is needed to identify the missing component.

The issue seems to be related to the ensurepip module. This module is used by venv to install pip and setuptools in the virtual environment. However, in this case, the ensurepip command returned a non-zero exit status, indicating that it failed to complete successfully.

To troubleshoot this issue, you can try running the ensurepip command with the -v option to enable verbose output. This may provide more information about why the command is failing.

Additionally, you can try installing pip and setuptools manually in the virtual environment by running the following commands:

python3 -m ensurepip --default-pip
source test_env/bin/activate
pip install --upgrade pip setuptools

This should install pip and setuptools in the virtual environment, allowing you to use it as expected.