0

I have a folder (python package):

app/
   __init__.py
   bases.py
   store.py

in store.py I have a the the code

from .bases import BaseStore

class Store(BaseStore):
    # .. class 

Everything works when I run the full project.
How can I run the store.py file itself? Running the file with Idle gives an import error.
How can I run a script in idle which will be aware to its package?

user3599803
  • 6,435
  • 17
  • 69
  • 130

1 Answers1

0

I am pretty sure that this is not an IDLE issue but one of the interaction between relative imports, sys.path, the current working directory, and how you start python. To find out for sure, add the following at the top of store.py.

import os, sys
print(os.getcwd())
print(sys.path)

Then run your code the two different ways. Also add, at a command line

python /path/to/app/store.py

This list is the equivalent of how IDLE runs your code.

Terry Jan Reedy
  • 18,414
  • 3
  • 40
  • 52