Configuring virtual environments
A virtual environment in Python is a self-contained directory that contains a specific Python interpreter version, along with a set of libraries and packages. It allows you to create an isolated environment for each of your Python projects, ensuring that dependencies are kept separate and do not interfere with each other.
Next, we will create a virtual environment in our PythonAnywhere Bash console to isolate our project code and dependencies. Let’s proceed with the following steps:
- To create a virtual environment in the PythonAnywhere Bash console we have to execute something like this command:
mkvirtualenv -p python3.10 <environment-name>
. For now, we will replace<environment-name>
withmoviesstoreenv
and run the following:mkvirtualenv -p python3.10 moviesstoreenv
We will see the name of virtualenv in Bash, for example, (moviesstoreenv). This means we are in the virtual environment (Figure 13.10):
...