Python Forum

Full Version: newbie question....importing a created class
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello all....
I've created a class in a directory using Python. I go to my command line to import and I get an error 'ModuleNotFoundError'.

Can someone tell me where I edit Python so that when it runs it will have a pointer to my location and be able to import files?

Thanks
Please make sure to post full (though minimal) code for reproducing the issue, as well as the full error message.
Sounds like your class is not somewhere Python can find it. Start python and type:
import sys
print('\n'.join(sys.path))
Does the module you are trying to import reside in or in a subdirectory of one of the listed directories?
no it does not reside in any of the listed directories
You can move the module to be in the same directory you are working in, you can move your module so it is in a subdirectory of one of the directories in sys.path, or you can add the directory for the module to sys.path.
I prefer not to move the files....my files exist at /home/pi/my_Python/Radar

the python path is:

Output:
>>> print('\n'.join(sys.path)) /usr/lib/python37.zip /usr/lib/python3.7 /usr/lib/python3.7/lib-dynload /usr/local/lib/python3.7/dist-packages /usr/lib/python3/dist-packages
I have included
#! /usr/bin/python
at the front end of the module containing the class

Would like to add the directory to the python path so that I can just use import?