0

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!

3
  • How do you execute ˋmain.pyˋ? Are you aware of ˋ__main__.pyˋ? Commented Oct 7, 2019 at 18:22
  • facing problem in pycharm or executing through terminal? Commented Oct 7, 2019 at 18:37
  • Try adding an __init__.py file to your scripts folder as well. Then use from scripts import utils. Failing that, check your sys.path and working directories. Commented Oct 7, 2019 at 18:37

1 Answer 1

1

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 * 
Sign up to request clarification or add additional context in comments.

1 Comment

its /__init__/.py not init.py

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.