Explore Courses Blog Tutorials Interview Questions
0 votes
in Python by (47.6k points)

Python is installed in a local directory.

My directory tree looks like this:

(local directory)/site-packages/toolkit/

My code is here:

(local directory)/site-packages/toolkit/examples/

To run the example, I write python, and in the code I have:

from toolkit.interface import interface

And I get the error:

Traceback (most recent call last):

File "", line 28, in ?

  from toolkit.interface import interface

ImportError: No module named toolkit.interface

I have already checked sys.path and there I have the directory /site-packages. Also, I have the file in the toolkit folder to indicate to Python that this is a package. I also have a in the examples directory.

I do not know why Python cannot find the file when it is in sys.path. Any ideas? Can it be a permissions problem? Do I need some execution permission?

1 Answer

0 votes
by (106k points)
edited by

To get rid of this error you just need to create in the appropriate directory and everything will work fine.

To know more about this you can have a look at the following video tutorial:-

If you wish to learn more about Python, visit Python tutorial and Python Certification by Intellipaat.

Browse Categories