For some reason I receive an ImportError
every time I try to import a class from another file. Here's the github page for my project: https://github.com/wheelebin/mcnextbot
Here's the error that I'm receiving:
Traceback (most recent call last):
File "ircbot.py", line 36, in <module>
from test import mcnextlvl
ImportError: cannot import name mcnextlvl
Here your from test import something
refers to the module test
in <PYTHONPATH>/lib
, not yourselves test.py
, and there is no submodule/class mcnextlvl
there. You should use from lib.test import mcnextlvl
as @sgmart commented.
__init__.py
python文件允许您从lib包中导入名为'test'的各个模块。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.