On Windows with virtualenv
:
- Open the Command Prompt in Windows.
- Navigate to the desired directory for your project using
cd
. - Install
virtualenv
if you haven’t already withpip install virtualenv
. - Create a new virtual environment with
virtualenv environment_name
. - Activate the virtual environment with
environment_name\Scripts\activate
. - Install and manage your project’s dependencies within the virtual environment.
- Deactivate the virtual environment with
deactivate
when you’re done.
On macOS with venv
:
- Open the Terminal on macOS.
- Navigate to the desired directory for your project using
cd
. - Create a new virtual environment with
python3 -m venv environment_name
. - Activate the virtual environment with
source environment_name/bin/activate
. - Install and manage your project’s dependencies within the virtual environment.
- Deactivate the virtual environment with
deactivate
when you’re done.
Server and cloud case:
pip install virtualenv
virtualenv ~/<name venv>
source ~/<name venv>/bin/activate
These methods allow you to create isolated virtual environments for your Python projects, making it easy to manage dependencies and specific package versions for each project. Choose the method that best suits your operating system and needs.