0

I have my files like this:

main.py
folder/
    __init__.py
    file_to_import.py
    other_file_used_by_file_to_import.py

I get a ModuleNotFoundError when I use import folder.file_to_import

then I tried from .file_to_import import function then I get a

ModuleNotFoundError: No module named '__main__.admin_menu'; '__main__' is not a package

can't seem to be able to find who to do this properly in python3.

  • 1
    Show how you're running this, I suspect you should be using [`python -m module`](https://github.com/asottile/scratch/wiki/PythonPathSadness) instead of `python file.py`. – anthony sottile Aug 24 '18 at 00:58
  • But I want to run the code in file.py and use certain functions from module. I use a bash script to activate my virtual env and run the python inside the virtual env – Rafael Cenzano Aug 24 '18 at 01:23
  • If you show how you're invoking things in the question we can tell you how to import *and* how to use the commandline in your bash script – anthony sottile Aug 24 '18 at 02:11

0 Answers0