Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

Can't import module from local folder? "No module named"

$
0
0

I don't find the mistake in the code nor in the call when trying an import test.

My directory structure is the following: (from /home/user1/python_test/)

main.pyAux/lib1.pyAux/__init__.py

main.py:

from Aux.lib1 import fun_Aif __name__ == "__main__":    fun_A()    print("all done")

Aux/lib1.py:

def fun_A():    print("A function called")

I'm executing from terminal (python main.py from directory where main.py is), maybe is there a need to set pythonpath? I don't recall the need before, I've made some python programs like these some time ago (2/3 years)

I have also tried from .Aux.lib1 import fun_A instead of from Aux.lib1 import fun_A but nothing works. The error is:

  File "main.py", line 1, in <module>    from Aux.lib1 import fun_AImportError: No module named Aux.lib1

Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>