Search code examples
pythonpython-idleghost.py

Code behaves different in IDLE and in py script - ghost.py


from ghost import Ghost

running it from IDLE works; but if I run a py file with only this line of code it get this error.

Traceback (most recent call last):
  File "C:\Users\Teo1\Desktop\sub\ghost.py", line 1, in <module>
    from ghost import Ghost
  File "C:\Users\Teo1\Desktop\sub\ghost.py", line 1, in <module>
    from ghost import Ghost
ImportError: cannot import name Ghost

It may seem a stupid question, but what it's so simple that I can't find my error.

I'm using ghost.py with PySide, both installed with pip.


Solution

  • Your program is trying to import itself, since the first module ghost it finds is your ghost.py.

    Renaming your program will fix this problem.