at application/app/folder1/file.py
How do I import application/app2/folder2/import_file.py?
from application.app.folder2.import_file import func_name I thought this would work, but it's not working ㅜ<
I think there's a way, but I'm not sure. Help me
python python-import import-에러
The Python default setting allows you to import only files in the same directory as the script to run, or files in sys.path
You must set path to import files in different directories.
To add a path to sys.path, write like this in the Python script
# file.py
import sys
sys.path.insert(0, '/path/to/application/app/folder2')
import import_file
© 2024 OneMinuteCode. All rights reserved.