###### tags: `Notes` `Python` `Environments`
# Creating Python Environments
---
- There are 2 types of Virtual environments you can create for most python applications. Sometimes one is better than the other
- pipenv is good for flask apps where the requirements for each application will be different.
- Commonly used for Flask Apps
- venv is good for universal or multi app use
- Commonly used for Django (but great for windows users with Flask)
## pipenv
- This one doesn't always run well on Windows computers as it's not a fan of bash
- Works fine on any mac terminal
1. Make sure that pip is installed
2. That you are in the folder of the application location
3. In Terminal
```
pip install pipenv
pipenv install Flask
```
4. For some you may have to do the following
```
python -m pipenv install flask
```
5. Continue installing any other packages needed for the application
6. Then activate the environment
```
pipenv shell
OR
python -m pipenv shell
```
7. Deactivate environment
```
exit
```
## Django
- This one lives on the device only so slightly less portable but can be easier
1. Make sure pip is installed
2. Create a environments folder outside of where any project will live
3. In terminal
```
cd into the environments folder
pip -m venv myEnv (myEnv is just the name your are giving the universal environment)
```
4. Now activate the environment
```
Windows:
source myEnv/Scripts/activate
Mac:
source myEnv/bin/activate
```
5. Install pip packages needed for the application
```
pip install django
```
6. You can install packages from anywhere in the system as long as it is activated
7. If you know the path relative to your current terminal location you can also activate it from any where
8. To Terminate the environment - can also be done from anywhere
```
deactivate
```