Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install my own python module (package) via conda and watch its changes

I have a file mysql.py, which I use in almost all of my projects. Since I do not want to copy and paste the same file into each of these projects I wrote a module - possibly a package in the future.

Question

How do I add a local module to my conda environment, and automatically update or watch it when I change something in mysql.py? How to do the same for a package?

I would like to avoid to set up a local channel/repository and just reference to the folder with mysql.py.

like image 878
Michael Avatar asked Mar 25 '18 09:03

Michael


People also ask

What is the difference between installing a package with conda and pip?

This highlights a key difference between conda and pip. Pip installs Python packages whereas conda installs packages which may contain software written in any language. For example, before using pip, a Python interpreter must be installed via a system package manager or by downloading and running an installer.

How do I install a custom package in Python?

To install a package that includes a setup.py file, open a command or terminal window and: cd into the root directory where setup.py is located. Enter: python setup.py install.


1 Answers

If you install the conda build package (and you have a package, not just a script), you can install in "editable" mode:

conda develop . 

(running from the directory with your script). This is very similar to the "editable" mode from pip

pip install -e . 

Either approach lets you uninstall packages with either

conda develop -u . 

or

pip uninstall . 

If you just have a script (not a package), you can edit or set the PYTHONPATH environment variable to include the directory with the script.

like image 63
darthbith Avatar answered Sep 21 '22 22:09

darthbith