It is suggested to have a dedicated virtual environment for each Python/Django project, and one way to manage a virtual environment is venv, which is included in Python. The name of the virtual environment is your choice, in this tutorial we will call it myenv. Type the following in the command prompt:
Windows:
1 | py -m venv myenv |
Unix/MacOS:
1 | python -m venv myenv |
This will set up a virtual environment, and create a folder named “myenv” with subfolders and files.
You must activate the virtual environment every time you open the command prompt to work on your project. You can activate the environment by typing this command:
Windows:
1 | myenv\Scripts\activate.bat |
Unix/MacOS:
1 | source myworld/bin/activate |
Once the environment is activated, you will see this result in the command prompt:
Windows:
1 | (myenv) C:\Users\Your Name> |
Unix/MacOS:
1 | (myenv) ... $ |
You can deactivate the virtual environment by typing this command:
1 | deactivate |
Django, Python, Virtual Environment — Mar 12, 2023
Made with ❤️ and ☀️ on Earth.