Ошибка ImportError: cannot import name "..." from "..."
есть 3 файла: main.py / cf.py / fn.py но при запуске main.py вылезает ошибка:
ImportError: cannot import name 'hey' from 'fn'
main.py:
from fn import hey
from cf import cmds
def cherk(vc):
if vc in question.cmds('hey'):
sic(x)
cf.py
from fn import *
class question:
cmds = {
('hey','hello'): hey
}
fn.py
class answer:
def hey(self, vc):
self.hey_rand = ['hello' , 'hello my friend']
x = random.choice(hey_rand)
def __init__(self, arg):
super(vc, self).__init__()
self.arg = arg
Ответы (2 шт):
Автор решения: Эникейщик
→ Ссылка
В fn нет hey, в fn есть класс answer, в котором есть функция hey. Точно так же в cf нет cmds.
После того как будут исправлены эти ошибки, вылезет еще пара других.
Автор решения: Pikuto
→ Ссылка
Цикличная зависимость циклов, лучше использовать:
import SomeModule
def someFunction(arg):
from some.dependency import DependentClass