ImportError: unable to import Ghost name

I know that there are similar questions, but I could not find a solution for this. Here is what I did.

I installed the ghost module using pip. The site-packages / ghost folder contains 3 files __init__.py , ghost.py and test.py

__init__.py has the following content

 from ghost import Ghost from test import GhostTestCase 
Module

offers a method

 from ghost import Ghost 

But this causes the following error.

 File "<pyshell#3>", line 1, in <module> from ghost import ghost File "G:\Python33\lib\site-packages\ghost\__init__.py", line 1, in <module> from ghost import Ghost ImportError: cannot import name Ghost 

I tried to add the path to PYTHONPATH; it did not work. I canโ€™t understand why this is happening with the standard module. I work in python 3.3

+4
source share
4 answers

With Python 3, try changing this line in __init__.py to

 from .ghost import Ghost 

do relative import packages. If this works, this is a bug in the module, and you should report it .

+6
source

What is your command line command? Must be pip install Ghost.py and not pip install ghost

0
source

I had the same problem

If the script file is named ghost.py or ghost.py , you must rename them to a name other than ghost .

After that, you need to delete the .pyc files that were made by previous scripts.

Now you can run your code.

0
source

You made a typo with the request

  from ghost import ghost 

instead

  from ghost import ghost 

Does a ghost module attempt to import a โ€œghostโ€ instead of a โ€œGhostโ€ that produces an error?

-1
source

All Articles