Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to import custom module in python

I want to import my custom written functions in any script on any directory, just like I import requests module in any script. I am running Ubuntu and Python 3.9

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

You could make a simple package of your custom functions and then just install the package in your system locally using pip. After this you will be able to import the functions from any script.

# for example
pip install .

# or if you need to edit your functions install in editable mode
pip install -e .

Note: the dot ‘.’ above indicates that your setup.py is located in the current working directory. You can also provide the path to the setup.py for your package instead of the dot.
Reference on creating package: How to write a Python module/package?


Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading