Python Install Dependency Libraries Into Local Directory

Dec 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 envsource 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 syssys.path.append('lib')from flask import Flask

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.