How To Create Virtual Environment In Python?

Open a terminal or command prompt

Check your Python version with `python –version` or `python3 –version`

Create a virtual environment with `python -m venv venv`

Use `python3 -m venv venv` if required on your system

Activate it on Windows with `venvScriptsactivate`

Activate it on macOS or Linux with `source venv/bin/activate`

Verify the environment is active by checking the prompt or running `python –version`

Install packages with `pip install package_name`

Deactivate the environment with `deactivate`

Suggested for You

Trending Today