The preferred solution would be to create your own conda package (info here ).
Another solution would be to create a link between your package directory and any directory in sys.path. That way, when you ask python to import your package, anaconda will look in its various sys.path directories and will read the link to your package as if that package were in one of the sys.path directories.
Directory binding can be easily done using the ln (link_name) command. As an example:
ln -s /path/to/my/package /path/to/anaconda/lib/python2.7/site-packages/
The above link will allow you to import your package into the default anaconda environment from any directory. This will not affect any of the other environments.
If you want to add a package to a specific environment (for example, "myenv") in anaconda, you can associate the package with one of these specific sys paths of the environment:
ln -s /path/to/my/package /path/to/anaconda/env/myenv/lib/python2.7/site-packges/
Please note the following:
- Linking your package directory to the sys directory, rather than moving the package directory to the sys path, allows you to save your package in the directory of your choice.
The -s flag generates a soft link (very similar to a shortcut). If you move the directory of your package, the link will not work. Running ln without the -s flag creates a hard link (for example, a mirrored copy) that will not be affected by moving (or even deleting) the package directory. All the pros and cons of soft links and hard links are discussed here.
Windows users must use mklink. For information see here .
Mark hannel
source share