user1047
user1047

Reputation: 169

python import a local package

I have trouble to import a local package. The code from github has below structure.

/ProjectA
/ProjectA/algorithms/...
/ProjectA/local_packages/internal-python3.zip
/ProjectA/example.py

The zip file contains internal.py, setup.py, etc....

When I run the example.py, it gives an ModuleNotFoundError: No module named 'interval' at below line of script

from interval import Interval       

Any idea to solve this issue? Thanks in advance!

Upvotes: 1

Views: 363

Answers (1)

Alejandro Puig
Alejandro Puig

Reputation: 31

First make sure you have unzipped the file. After that if you want to make a specific folder into a local package, inside the desired folder you need to create a file named init.py It can me a blank file

So in the case of interval folder, you need to have /interval/init.py

Upvotes: 1

Related Questions