user3565319
user3565319

Reputation: 3

ImportError: cannot import name

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

Upvotes: 0

Views: 5946

Answers (2)

counsellors
counsellors

Reputation: 11

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

Upvotes: 1

zhangxaochen
zhangxaochen

Reputation: 34047

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.

Upvotes: 1

Related Questions