-1

I have a python folder like this. How to import file1.py in pkg2/file2.py

enter image description here

I tried to import like this in file2.py

`

from pkg1 import file1

` But i got error like this

enter image description here

Could someone help me out.

Suganth
  • 1
  • 1
  • 1
    Does this answer your question? [Importing files from different folder](https://stackoverflow.com/questions/4383571/importing-files-from-different-folder) – ouroboros1 Oct 26 '22 at 04:27

1 Answers1

0

If you set the PYTHONPATH environmental variable to the root folder, it should work, e.g on Windows:

set PYTHONPATH=. && python pkg2\file2.py
J. Doe
  • 9
  • 3