I have the following structure:
repo_folder
|--> main.py
|-->_init_.py
|--> scripts (folder)
|---> utils.py
I want to import all the classes/functions in utils.py to main.py to do that I tried the following things:
1) from scripts.utils import *
got an error that scripts module wasn't recognized.
2) moved main under scripts and edited the line from.utils import *
I use python 3.6.8 on Ubuntu 18.04 when trying (1) no errors marks shown over the IDE (Pycharm)
Thank you for helping!
Try to add " init .py" file to the scripts folder, It's will turn the folder to python package.
and than try
from scripts.utils import *
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.