How can I prevent Anaconda from caching my module? Every time that I make a change in a specific file in my codebase (for which the containing folder has a __init__.py
file), python does not recognize those changes and keeps executing the previous version of the file, which happens to be cached at anaconda3/lib/python3.6/site-packages/"the name of the main module"
.

- 353
- 3
- 12
1 Answers
If you are doing development of a package, it is best to use the develop
option to one of the installers. This creates a link to the development directory, rather than copying files, so you can test your updated code. For instance, if you have a directory like:
project
|── setup.py
|── package_name/
|── __init__.py
|── module.py
You can install in development mode by running one of the following commands in the directory with setup.py
(and note that the dots .
at the ends of the commands are important):
conda develop .
(requiresconda-build
to be installed)- Uninstall with
conda develop --uninstall .
- Uninstall with
pip install -e .
- Uninstall with
pip uninstall package_name
- Uninstall with
python setup.py develop
- Uninstall with
python setup.py develop --uninstall
- Uninstall with
In your situation, what you should do is remove the installed package, either with conda
or pip
, depending on how you installed it, and then use the develop mode to incorporate changes in your code.
Note that you will need to restart the Python interpreter (if you're running in interactive mode) every time you want to use the changed code. Another option is to use IPython and the autoreload
extension, although note the caveats about using that in the documentation.
Also related: Python setup.py develop vs install

- 18,484
- 9
- 60
- 76
-
Think I'm having same issue. – openwonk Jul 15 '19 at 08:17