If you hit an error like “No module found”, “the xxxx is not installed”, you are not likely to be in the virtual environment. In Codespaces, we have two separate environment, base
and venv
. Each environment has its own set of software packages. The assignment is built on the venv
environment. And you hit the “No module” error because you might be in the base
environment. To solve this, activate the virtual environment named by typing the following line in the terminal:
source /home/vscode/venv/bin/activate
You can check if you are in the base environment or virtual environment through the prefix of your command line:
In the first line, I am still in the base environment. By typing the command above, you should see this (venv)
before your username.
Sometimes, Codespaces fails to create a virtual machine (and you will see a pop up window saying “Running in Safe Mode”). This is likely due to an excessive amount of disk space being assigned to the Docker image caches. A simple solution is to rebuild Docker. Please refer to the step-by-step instructions provided here: