문제

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.

다른 팁

The __init__.py python file allow you can import your individual modules named 'test' from the lib package.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top