Create a virtual environment for your Python app in a few steps. (For Linux and OS X). Go inside the directory where you want your virtual environment and type in the terminal:
1 |
python3 -m venv myvenv |
This command will create a directory called myvenv with the virtual environment.
Start your virtual environment by running:
1 |
source myvenv/bin/activate |
Now that you inside the virtual environment (you will know it because the prompt of the console is prefixed with ( myenv )) you can install whatever you need using pip. To get the latest version of pip type:
1 |
python -m pip install --upgrade pip |
When working within a virtual environment, python will automatically refer to the correct version so you don’t need to specify anything.
Create a requirements.text file and add packages inside.
Run the following to install them:
1 |
pip install -r requirements.txt |
The end! Happy coding!