How to add a folder with Python packages to Anaconda path

To permanently include packages or folder into the PYTHONPATH of an Anaconda environment, activate the Conda environment and use [conda develop](https://docs.conda.io/projects/conda-build/en/latest/resources/commands/conda-develop.html) to add the path permanently to the PYTHONPATH of the Conda environment.

conda develop /PATH/TO/YOUR/FOLDER/WITH/MODULES

This command will create file named conda.pth file the site-packages folder of your environment.

~/anaconda3/envs/YOUR_ENV/lib/pythonX.X/site-packages

As an alternative, you can just add a conda.pth file in ~/anaconda3/envs/YOUR_ENV/lib/pythonX.X/site-packages with the folder that you want to include in your PYTHONPATH. The filename can be different as long as it has the pth extension. Every line of the file can contain a folder.

You can also modify your .pth files to add new folders or remove them from your Conda PYTHONPATH.

Related