Python Install Dependency Libraries Into Local Directory

December 22, 2018

Create requirements.txt to list of depedency libraries.

# Check latest version: https://pypi.python.org/pypi/Flask
Flask==0.12.2
Flask-SQLAlchemy==2.3
MySQL-python==1.2.5
python-dateutil==2.6.1

Install virtualenv.

sudo -H pip install virtualenv

Create a virtualenv named env and activate it.

virtualenv env
source env/bin/activate

Install dependencies into lib directory.

pip install -t lib -r requirements.txt

Deactivate env.

deactivate

Python files to include the lib directory.

import sys
sys.path.append('lib')

from flask import Flask
This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.