- Install Python 3
- On a Unix-based OS, the system's default Python installation is normally Python 2. Check this by running
python --versionon a terminal. If this is so, install Python 3 but DO NOT REMOVE / OVERWRITE / UNINSTALL the old Python 2. The system uses Python 2 for its internal scripts and removing it may break the OS installation. - For Linux, either install it from
aptor from source - For Mac, use Homebrew
- Verify the Python installation by running
$ which python3 $ python3 --version
- On a Unix-based OS, the system's default Python installation is normally Python 2. Check this by running
- Setup and use a virtual environment
- There are many different modules for creating a virtual environment
- If Python 2 support is needed, use the virtualenv module
- If Python 3 only, use the built-in venv or pipenv
- For
venv- Set
VENV_DIRto directory for virtual environments (ex.$HOME/.venvs) - Copy the bash aliases for using venv
mkvenv PROJECT_NAMEupvenv PROJECT_NAMEdnvenvrmvenv PROJECT_NAMElsvenv
- Set
- For
pipenv- Set
WORKON_HOMEto directory for virtual environments (ex.$HOME/.venvs) - How to set
pipenv shellprompt to match the Terminal's PS1 prompt?
- Set
- For
- For each Python project
- For
virtualenvandvenv- Create/Activate a virtual environment
$ mkvenv NAME /path/to/python
- Create a requirements.txt file
$ pip freeze > requirements.txt - Commit the requirements.txt file
- When switching environments:
$ pip install -r requirements.txt
- Create/Activate a virtual environment
- For
pipenv- Create/Activate a virtual environment
$ pipenv --python=/path/to/python
- Create a
Pipfile$ pipenv install PACKAGE $ pipenv install --dev PACKAGE
- Commit the generated
PipfileandPipfile.lock - When switching environments:
$ pipenv sync
- Create/Activate a virtual environment
- For
- The FAQ list every Python developer MUST first read
- How does
importwork? - Public and Private
- Metaclasses
- ipython - Enhanced interactive Python shell
- colorama - Cross-platform colorizer for console logs
- click - For creating CLI-based applications
- tqdm - For better progress bars and loop tracking
- flask - Lightweight web application framework
- bokeh - Interactive and embeddable images for modern web browsers