Home > OS >  How can I import module from another folder which is not same directory structure
How can I import module from another folder which is not same directory structure

Time:01-05

I have two directory on same level

1.Scripts->(Inside it we have app.py file)
2. Keymaker-->(Inside it we have keymaker.py file)

Now I want to import keymaker.py in app.py, So how Can I do it

CodePudding user response:

Write these lines in app.py file.

import sys
sys.path.append('path/to/Keymaker/dir')

After that you can import anything from keymaker.py file using from keymaker import *

CodePudding user response:

Add empty __init__.py file to Keymaker directory and do from Keymaker import keymaker

  •  Tags:  
  • Related