我有一个类名为JCheq,其中有一个名为'logger'的静态变量。
JCheq导入了模块“printing_systems”,但我需要在“printing_systems”中使用“JCheq.logger”。
在将“import JCheq”放入“printing_systems.py”后,我的代码无法编译。
jcheq.py
JCheq导入了模块“printing_systems”,但我需要在“printing_systems”中使用“JCheq.logger”。
在将“import JCheq”放入“printing_systems.py”后,我的代码无法编译。
jcheq.py
from printing_systems import printing_systems
from logger import logger
class JCheq:
logger = logger.Logger('logs/jcheq.log', loglevel=logger.Logger.INFO)
def __init__(self):
pass
...
printing_systems/printing_systems.py
from jcheq import JCheq
class WinLPR:
def __init__(self):
pass
@staticmethod
def send(spool, params):
temp_dir = tempfile.mkdtemp()
try:
JCheq.logger.log('Creando archivo temporal en dir: ' + temp_dir, logger.Logger.TRACE)
错误追踪:
Traceback (most recent call last):
File "/home/jsivil/Desktop/Proyectos/UNPAZ/jcheq/jcheq/jcheq.py", line 12, in <module>
from printing_systems import printing_systems
File "/home/jsivil/Desktop/Proyectos/UNPAZ/jcheq/jcheq/printing_systems/printing_systems.py", line 7, in <module>
from jcheq import JCheq
File "/home/jsivil/Desktop/Proyectos/UNPAZ/jcheq/jcheq/jcheq.py", line 12, in <module>
from printing_systems import printing_systems
ImportError: cannot import name 'printing_systems'
printing_systems
模块中有一个名为printing_systems
的变量吗?你正在尝试从模块中导入一个变量,而不是只导入import printing_systems
。 - Tadhg McDonald-Jensen__init__.py
文件,对吧? - Tadhg McDonald-Jensen