1

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:

packer.py
parser.py
statistics.py

packer.py

class Conversation:
    ....
class Message:
    ....

parser.py (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():
    ....

statistics.py

from parser import getConvs  #this on its own runs without problems
getConvs() #throws ImportError: cannot import name 'getConvs'
Ilhan
  • 1,309
  • 10
  • 24

1 Answers1

2

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

Karin
  • 8,404
  • 25
  • 34
  • Seems likely, but the question does say that the import statement ran fine. – OneCricketeer Aug 11 '16 at 15:45
  • they are located in the same folder afaik, so `parser.py` shadows the built-in and is used. – Dimitris Fasarakis Hilliard Aug 11 '16 at 15:46
  • you were right, name change fixed it.. but why didn't it work because it was in the same folder (also the import itself ran fine, it should have crashed after trying to import a non existing function from pythons parser module?) – Ilhan Aug 11 '16 at 15:50