I created a new project (myproject) and 3 python files in a row (mainscript.py, module1.py, module2.py) in the directory. In main script, I coded:
import module1
import module2
The two empty modules were imported without problem. After this, I created a 3rd python file (module3.py) in the same directory. When I tried to run:
import module3
I got the message:
Traceback (most recent call last):
File "E:\anaconda\lib\site-packages\IPython\core\interactiveshell.py", line 3331, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-6-b4e6aa7db43e>", line 1, in <module>
import module3
File "E:\pycharm\PyCharm Community Edition 2020.1.2\plugins\python-ce\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ModuleNotFoundError: No module named 'module3'
Can someone explain why the first two files are detected and not the third?
After trying several times the experiment, it seems that only the files created before I run for the first time import function will be found.