Apart from writing correct code like from ghost import Ghost
, you may like to follow steps outlined below.
Download ghost.py
master file from https://github.com/jeanphix/Ghost.py/archive/master.zip
Unzip contents of master.zip
to C:\ghost-master
folder
If you carefully watch the folder structure then you find that ghost\__init__.py
file has following content.
from .ghost import Ghost, Error, TimeoutError
from .test import GhostTestCase
While ghost\ext\__init__.py
is of 0 KB
In this case, when you run following command to build the package.
C:\<path_to_Python_folder>\python.exe setup.py build
you see that apart from other lines, following line also appears.
copying ghost\ext\__init__.py -> build\lib\ghost\ext
It means that __init__.py
of 0 KB size is being copied as build\lib\ghost\ext\__init__.py
Therefore, even though installing ghost.py with following command does not produce any error, you face ImportError: cannot import name Ghost
.
C:\<path_to_Python_folder>\python.exe setup.py install
So, to solve the problem, before building the package overwrite __init__.py
file
C:\ghost-master>copy ghost\__init__.py ghost\ext\
Now issue following commands.
C:\<path_to_Python_folder>\python.exe setup.py build
C:\<path_to_Python_folder>\python.exe setup.py install
Now you will not see ImportError: cannot import name Ghost
I have tested above solution with Python 2.7.6