How To Create Virtualenv In Python?

Open a terminal or command prompt

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

Install `venv` if needed

Create a virtual environment with `python -m venv myenv` or `python3 -m venv myenv`

Activate it on Windows with `myenvScriptsactivate`

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

Verify activation by checking the terminal prompt

Install packages with `pip install package_name`

Deactivate the virtual environment with `deactivate`

Suggested for You

Trending Today