This is an old revision of the document!
Table of Contents
Python Development Workflow
Node.js has npm
and package.json
files, PHP has composer
and composer.json
files, and Python has pip
and virtual environments, which don't work quite like npm
and composer
.
Projects require virtual environments
The basic idea is that for each Python project, you define a virtual environment that harbors all the project's python dependencies.
The easiest way to go about things assuming your have pip
, virtualenv
and virtualenvwrapper
installed on your system is as follows:
- Create a directory for your project:
$ mkdir ~/Dev/MyProject
- Create a virtual environment for you project:
$ mkvirtualenv MyProject
The actual virtual environment will be in
~/.virtualenvs/
. - Enable the virtual environment:
$ workon MyProject
- Install the packages you need:
$ pip install <whatever>
- When you are done, switch your shell back to “regular” mode:
$ deactivate
Notes
- To see what environments are available:
$ workon
without an argument.
- To set the Python version you want to use:
$ mkvirtualenv -p /usr/bin/python3 MyProject
Getting a list of packages in the virtual environment
When you want to deploy your project on another machine, you will want to use the same versions of the packages you used while developing it (i.e., those in the virtual environment). To do this TODO.
Virtual environments and IDEs
What about if you want to use an IDE or other GUI tools? TODO