pythonpackagevirtualenvpippythonpath

Access a Python Package from local git repository


I have a local git repository on my machine, let's say under /develop/myPackage.
I'm currently developing it as a python package (a Django app) and I would like to access it from my local virtualenv. I've tried to include its path in my PYTHONPATH (I'm on a Mac)

export PATH="$PATH:/develop/myPackage"

The directory already contains a __init__.py within its root and within each subdirectory. No matter what I do but I can't get it work, python won't see my package.

The alternatives are:

Since I often need to make changes to my code the last two solution would require too much work all the time even for a small change.

Am I doing something wrong? Would you suggest a better solution?


Solution

  • Install it in editable mode from your local path:

    pip install -e /develop/MyPackage
    

    This actually symlinks the package within your virtualenv so you can keep on devving and testing.