To create a virtual environment in Python, follow these steps:
Open a terminal/command prompt window.
Navigate to the root directory where you want to create your virtual environment.
Run the following command to create a new virtual environment:
main.py21 chars2 lines
Replace "myenv" with any other name you want to give to your virtual environment.
Activate the newly created virtual environment by running the appropriate script:
On Windows:
main.py27 chars2 lines
On Unix or Linux:
main.py26 chars2 lines
You should now see your prompt reflecting that you are working inside the virtual environment.
You can now install packages specific to this virtual environment using pip, without affecting other projects or the system installation:
main.py25 chars2 lines
When you are done working in the virtual environment, you can deactivate it by running the following command:
main.py11 chars2 lines
gistlibby LogSnag