Cannot import class from local modules in python

前端 未结 2 1465
梦如初夏
梦如初夏 2021-01-27 11:57

I have a module parser.py in local directory with

class Parser(object):
    . . . .
    . . . . 

class Parser2(object):
    . . . .
    . . . . 
相关标签:
2条回答
  • 2021-01-27 12:23

    Parser is already a Python module. Rename your module (for example from "parser.py" to "myParseModule.py") and you shouldn't have a problem.

    0 讨论(0)
  • 2021-01-27 12:38

    check your sys.path. if /usr/lib/pythonX/lib-dynload is before '' you will be importing the official parser module from the standard library instead of your module.

    0 讨论(0)
提交回复
热议问题