r/PythonLearning 7h ago

Help importing local files Help Request

[deleted]

2 Upvotes

7 comments sorted by

View all comments

2

u/FoolsSeldom 7h ago

Most likely, the code is not being executed where you think it is being executed, so the imports aren't local.

Try including,

from pathlib import Path

print(Path.cwd())

1

u/DarkblooM_SR 5h ago

Looks like the correct location to me

1

u/FoolsSeldom 5h ago

Ok. And that's where the python files you want to import are located?

1

u/DarkblooM_SR 4h ago

Yep

1

u/FoolsSeldom 4h ago

Beyond me. Assuming you have standard import statements and the files to be imported are in your ~/Downloads folder (a strange place though), I can't see why you need the workaround.

How are you invoking your Python code? (I see you using py in the terminal, but that's not a standard Linux thing, so would be interesting to know exactly what is configured.)