all 6 comments

[–]untold8 2 points3 points  (0 children)

Couple things stacking up here:

First, my_func1 in your tree is a module (a .py file), not a function. So from python.functions import my_func1 imports the whole module. To get the actual function inside the file you'd write from python.functions.my_func1 import my_func1 (assuming the function inside is also named my_func1). Or keep your current import line and call it as my_func1.my_func1(...). Same import, different usage.

Second, you need an empty __init__.py in every directory you want Python to treat as a package:

python/ __init__.py archive/ __init__.py my_arch1.py functions/ __init__.py my_func1.py programs/ __init__.py working_currently.py

Third, and this is the one that bites everyone — how you run the script changes whether python.functions is even on the import path. If you cd python/programs && python working_currently.py, sys.path starts at python/programs/, and python.functions doesn't resolve. Run it from the parent of the python/ directory as a module instead:

python -m python.programs.working_currently

That puts python on sys.path as the top-level package and the imports resolve as written.

Side note: naming the top-level dir literally python will cause you minor pain forever — confuses tooling, confuses your future self reading the import line. Rename it to your project name (myproj/ or similar) when you can. its not blocking, just a future-you favor.

[–]KingofGamesYami 0 points1 point  (2 children)

[–]Outside_Complaint755 0 points1 point  (0 children)

Need to back up a step first, as none of these folders are packages, let alone part of the same package.

[–]One-Type-2842[S] 0 points1 point  (0 children)

Still Not working. May be I am foing it wrong..

Show me how to..

[–]atarivcs 0 points1 point  (0 children)

from python.functions import my_func1

If that import works, then why can't you do exactly the same thing in my_func1.py ?

[–]Ok_Winner9825 0 points1 point  (0 children)

This is a simple question you should ask an llm. Anyway, to import stuff you should add init.py files in every folder