2/19/2017 - 11:06 PM

Setup pipenv on macOS.md

Since I am going to work on a serious Python project D3HRE (Data Driven Dynamic Hybrid Renewable Energy framework). I am stand at the point to pick up my python development environment again.

Package and environment management: Pip + virtualenv = pipenv ~ conda

Create a new environment with pipenv:

pipenv --three

It will basiclly create a python 3 virtual environment and a pipfile if there wasn't any.

Creating a Pipfile for this project...
Creating a virtualenv for this project...
‚†čRunning virtualenv with interpreter /usr/local/bin/python3
Using base prefix '/Library/Frameworks/Python.framework/Versions/3.5'
New python executable in /Users/caoyu/.local/share/virtualenvs/D3HRE/bin/python3
Also creating executable in /Users/caoyu/.local/share/virtualenvs/D3HRE/bin/python
Installing setuptools, pip, wheel...done.

Virtualenv location: /Users/caoyu/.local/share/virtualenvs/D3HRE

Activate development shell

pipenv shell -c

will create a new shell session inside with new virtualenv python interpreter. This nice and clean environment is isolated from system's python.

Install packages with pipenv

pipenv install ipython

Besides normal pip install it also write packages info into Pipfile

If packages is only necessary for development simply add --dev argument

Exit and re-enter virtualenv to use new packages.

pipenv install --dev

Install all packages (including dev) packages