Question

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
Was it helpful?

Solution

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.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top