12 ŞUBAT 2012, Pazar
İmportError: alamıyor adı X
Dört farklı dosya var adı: ana, vektör, varlık ve fizik. Hatanın nerede olduğunu düşünüyorum çünkü tüm kodu, çoğunlukla sadece ithalat sonrası, vermeyeceğim. Ama eğer isterseniz, daha sonrası.
Ana:
import time
from entity import Ent
from vector import Vect
#the rest just creates an entity and prints the result of movement
Varlık:
from vector import Vect
from physics import Physics
class Ent:
#holds vector information and id
def tick(self, dt):
#this is where physics changes the velocity and position vectors
Vektör:
from math import *
class Vect:
#holds i, j, k, and does vector math
Fizik:
from entity import Ent
class Physics:
#physics class gets an entity and does physics calculations on it.
Ben o zaman main.py çalıştırın ve aşağıdaki hatayı alıyorum:
Traceback (most recent call last):
File "main.py", line 2, in <module>
from entity import Ent
File ".../entity.py", line 5, in <module>
from physics import Physics
File ".../physics.py", line 2, in <module>
from entity import Ent
ImportError: cannot import name Ent
Python için çok yeni değilim, ama uzun zamandır C ile çalışmış. Neden iki kez varlık ithal olduğunu tahmin ediyorum, ana, fizik ve daha sonra bir kez, ama bir çözüm bilmiyorum. Kimseye yardım?
CEVAP
12 ŞUBAT 2012, Pazar
Dairesel bağımlı ithalat var. physics.py
Ent
tanımlanmış ve physics
zaten başlatılıyor entity
almaya çalışır dersten önce entity
dan ithal ediliyor. entity
modülü physics
depency çıkarın.
Bunu Paylaş:
Ubuntu 12.04 yükseltme Python İmportEr...
Nasıl 'İmportError düzeltirim: al...
Alamıyor, keyfile 'falan filan.pf...
Android 2.3 SDK ve ADT 8.0'e yükseltme...
HATA: 1.2 çevre JNI alamıyor JDWP...