Cord Kaldemeyer Cord Kaldemeyer - 1 year ago 115
Python Question

Anaconda: Permanently include external packages (like in PYTHONPATH)

I know how to install packages in Anaconda using

conda install
and also how to build packages that are on PyPi which is described in the manual.

But how can I permanently include packages/folders in Anaconda e.g. with code that I am currently working on?

My current approach is to use

import sys

which is not really convenient.

Any hints?

Thanks in advance!

Answer Source

I found two answers to my question in the Anaconda forum:

1.) Put the modules into into site-packages, i.e. the directory $HOME/path/to/anaconda/lib/pythonX.X/site-packages which is always on sys.path.

2.) Add a .pth file to the directory $HOME/path/to/anaconda/lib/pythonX.X/site-packages. This can be named anything (it just must end with .pth). A .pth file is just a newline-separated listing of the full path-names of directories that will be added to your path on Python startup.

Both work straightforward and I went for the second option as it is more flexible.

Thanks anyway!