Следующее работает отлично, но это всего лишь хак. Мне нужен рекомендуемый/питоновский способ.
Код: Выделить всё
import sys
sys.path.append("../")
from fruit import Fruit
print("OK")
Код: Выделить всё
pkg1
__init__.py
fruit.py
+sub_pkg
__init__.py
recipe.py
Код: Выделить всё
class Fruit:
def get_name(self):
print("Fruit name")
Код: Выделить всё
from fruit import Fruit
Код: Выделить всё
python recipe.py
Код: Выделить всё
Traceback (most recent call last):
File "recipe.py", line 2, in
from fruit import Fruit
ImportError: No module named fruit
Код: Выделить всё
python -m recipe.py