Forum Archive

ModuleNotFoundError when run from External Files

maxelon

If I try and run programs from an external file, it gives me a ModuleNotFoundError, even though the module is in the same folder and it runs perfectly from my Mac. For example,

File 1: (dummy.py) has this line:
print('Hello')

File 2: (dummy2.py) has this line:
import dummy

When I run File 2, on my Mac I get 'Hello' printed. On Pythonista, I get ModuleNotfoundError.

Can someone help me understand what is going on?

cvp

@maxelon for me, it works. Be sure no uppercase and in same folder

maxelon

Definitely no upper case and in the same folder, and it does works from my Mac. I can also make it work from Pythonista’s iCloud Script Library area, just not from a folder accessed by External Files.

cvp

@maxelon ok, sorry, I didn't read it correctly. It is normal, your import would no access your external folder.

cvp

@maxelon it works, if:
- I rename both .py into mydummy and mydummy2 (perhaps is dummy system reserved)
- I put both files in iCloud Drive/test folder (not Pythonista3 iCloud)
- I open external folder test
- I run mydummy2

maxelon

@cvp thanks. That fixed things. I had been trying with the individual files in the External Files area, but once I placed the whole folder in External Files, everything works, even with the ‘dummy.py’ name. Much appreciated.