Create a virtual environment for Python Projects
Tags: django, python, beginners, elechinotes
Published: 2022-01-23 01:58:58

Hello there, in this short note I'll show you how to create a python virtual environment for a new project and walk you through the process of resolving some common conflicts you might get while creating a virtual environment for your projects. 

### First things first, you will need to make sure **python** and **pip** are installed properly

### to check this just run the stuff below in your _favourite_ terminal

```terminal
  $ python --version
```
### if you an error like the one below, it probably because you don't have python correctly installed or you it haven't be added to your system **environment variables path**

![Image showing how to setup environment variable on windows](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lpmiqhvlzeje2o4xga57.png)

## Here's how to add it yourself 
### type "edit system environment variable" - follow the images below to get it resolved

#### Once you type that stuff from before, it should land you here, look to the bottom where it says environment variable CLICK IT !

![Image showing how to setup environment variable on windows](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wxnlgv5yu75staekmqoz.png)

That button should land you here, DOUBLE CLICK where that blue color stuff is on [path] just like the image below 



![Image showing how to setup environment variable on windows](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xpdbd6it5hhr0iznmc1q.png)

That double clicking should land you here, make sure yours is like mine in the picture below [especially the first two]


![Image showing how to setup environment variable on windows](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/76himc8nmkxnxteb86ts.png)

### Okay great, once you finish editing "click save" and go back to this area, and DOUBLE CLICK where my cursor is on the image below that has a blue background


![Image showing how to setup environment variable on windows](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wi4xe0ft4ytzbx0st91q.png)

It should land you here, make sure yours looks like mine, especially the last two variables 

![Image showing how to setup environment variable on windows](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xbc3azf9cy1ym8q1r73o.png)

when you are done, click save until the boxes disappear, you shouldn't be having error with python and pipenv 

## MOVING FARWARD and Installing Pipenv

Pipenv manages dependencies on a per-project basis. To install packages, change into your project’s directory (or just an empty directory) and run:

```terminal
  $ cd code_folder

  $ pip install pipenv --user 

  $ pipenv install requests
```
it does it what it does in creating a virtual environment for your project and out out some that looks like the image below...


![Image success on creating a virtual environment](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gifgjqf0nwh855g1szyc.png)

## You should be all set, if you want to use virtualenv instead of pipenv - all you need to do is run the commands below: 

```terminal
  $ pip install virtualenv --user
```
then to use it, run:

```terminal
  $ cd project_folder
  $ virtualenv venv
```
to activate it run:

```terminal
  $ source venv/bin/activate
```

## In summary to setup a virtual environment 

- install python

- install `pipenv`

- change the environment variables to point accordingly

- then run `pipenv install requests` on the folder you want to create your python project

## CHEERS, If you have questions, let me know in the comments 
## Thanks