- Best way is editable pip packages (reference)
pip install --editable /path/to/package
You need to include a minimal setup.py
from setuptools import setup, find_packages
setup(
name="packagename",
version="1.0",
author="[AUTHORNAME]",
description="[DESCRIPTION]",
packages=find_packages(),
)
p.s. It is also possible to use repositories as editable (thanks chatGPT)
pip install --editable git+https://github.com/user/repo.git#egg=package
- sys.path method
import os
import sys
#### Include upper dirs start
dpath = os.path.dirname(os.path.abspath(__file__))
for i in range(1): ## For more than one level of folders you can increase this number
dpath = os.path.dirname(dpath)
sys.path.insert(1, dpath)
#### Include upper dirs end
- Set a PYTHONPATH (I never tried this one)