how to use relative import within python spyder IDE -


i got anaconda python , using spyder ide. i'm trying figure out how can use relative import run bottom or f5.

suppose have pkg/a/foo1.py, pkg/a/foo2/py, , foo1.py has "from . import foo2", if hit run report relative import error.

i know how in command line environment can type, e.g. "python -m pkg.a.foo1". how can in spyder ide?

thanks jq

if there pkg/a/__init__.py file i.e., if pkg.a python package from . import foo2 correct. doesn't matter write code in spyder ide, notepad, or emacs; code same.

the remaining question how run python scripts in spyder ide.

don’t directly run modules inside packages i.e., don't run python pkg/a/foo1.py. leads python modules being available under different names. see traps unwary. run python -m pkg.a.foo1 project directory instead.

configure command run on f5 if spyder ide allows it.


Comments

Popular posts from this blog

c++ - How to add Crypto++ library to Qt project -

jQuery Mobile app not scrolling in Firefox -

How to use vim as editor in Matlab GUI -