Module not found error when file exists in same directory

Question:

I am running python 3-32 bits on my windows computer. And here is my directory structure:

device_controller
  device_controller.py
  kestrel_main.py

And in the device_controller.py file, I have the import line as so:

from kestrel_main import mainKestrel

And I do have a mainKestrel() function defined in the kestrel_main.py file.

However, whenever I try to run the device_controller.py script, I get a "ModuleNotFoundError: no module name kestrel_main".

I run the script by typing the absolute path of the python 3-32bit executable followed by "device_controller.py". So as in

{absolute path of python} device_controller.py

Any ideas on why I get this error?

Answers:

Sounds like you have incorrectly installed python3-32. I would suggest removing the download files from your computer and then re-downloading. But make sure you download the installer and not the zipped file. After you do this, either add python to the path or reference the absolute path to python.exe every time you run your script.

Your current method of importing the module is correct.

Answered By: Duck Dodgers
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.