How to use relative import in python spyder IDE

I have anaconda python and use the spyder IDE. I am trying to figure out how I can use relative imports for the bottom or F5.

Suppose I have pkg / A / foo1.py, pkg / A / foo2 / py, and foo1.py has "from. Import foo2", if I click on start it will report a relative import error.

I know how to do this in a command line environment where I can print, for example. msgstr "python -m pkg.A.foo1". How to do it in spyder IDE?

Thanks jq

+1
source share
1 answer

pkg/A/__init__.py i.e, pkg.A - Python, from . import foo2 . , IDE spyder, emacs; .

, Python spyder IDE.

, .. python pkg/A/foo1.py. , Python . . python -m pkg.A.foo1 .

, F5, IDE spyder.

-1

Source: https://habr.com/ru/post/1539718/


All Articles