Include All Libs

To make include all dependencies of a script into a copyable folder so that it can be copied and executed on a different computer without internet access to load the dependencies itself, you can load the dependencies into a subfolder and then tell the script where to find them.

python -m pip install --target ./lib -r requirements.txt

Then edit your main.py file (or your script) and make sure these are the top most lines (only the #!/usr/bin/pythonor similar can come before that):

import sys
from pathlib import Path
# Setup lib folder
sys.path.insert(0, str(Path(__file__).parent / "lib"))

This enables you to load following imports from the lib folder.

This page was last edited on 2026-09-19 22:45

Powered by Wiki|Docs

This page was last edited on 2026-09-19 22:45

Bjørn Singer
Private wiki!

Powered by Wiki|Docs