Ilhan Ilhan - 1 year ago 198
Python Question

Python3 Cannot import function from my own module

I have browsed the site for a while and the only occasions people had this error happening were in circular imports which I don't have as far as I understand what circular imports are? My imports are transitive though.

I have 3 files in the same folder:

class Conversation:
class Message:
.... (module works, called all functions from itself without a problem)

from bs4 import BeautifulSoup
from packer import Conversation
from packer import Message

def writeFormatedLog():
def getConvs():

from parser import getConvs #this on its own runs without problems
getConvs() #throws ImportError: cannot import name 'getConvs'

Answer Source

ImportErrors may happen if there are duplicate module names. Try naming your something else, since it is likely conflicting with Python's built-in parser module.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download