Install and run your project in python virtual Environment

Install and run your project in python virtual Environment

In this article, we’ll show you how to install virtual environment in your system and run your python project in virtual environment. A virtual environment is important if you don’t want to disturb what you install for a specific project to others in the same system. You can have multiple virtual environments in one system and each project requirement can be kept in a specific python environment. It is the best practice while working in a python project.

Step 1: Install or upgrade pip

python3 -m pip install --user --upgrade pip

Step 2: Check pip version (optional)

python3 -m pip --version

Step 3: Install Virtual Environment on macOS and Linux

python3 -m pip install --user virtualenv

On Windows

py -m pip install --user virtualenv

Step 4: Creating Virtual Environment

On macOS and Linux

 virtualenv -p python3 YOUR_ENVIRONMENT_NAME

On Windows:

py -m venv YOUR_ENVIRONMENT_NAME

Step 5: Activating a virtual Enviroment
You should activate your virtual environment to install all the dependencies for your specific project.

On macOS and Linux

source YOUR_ENVIROMENT_NAME/bin/activate

On Windows:

.\env\Scripts\activate

Leave a Reply

Your email address will not be published. Required fields are marked *