hipspy / hips

Python library to handle HiPS
https://hips.readthedocs.io
12 stars 16 forks source link

ImportError: cannot import name 'WCSGeometry' #121

Closed ggreco77 closed 6 years ago

ggreco77 commented 6 years ago

Hi, after installing hips (python3.6.3 in centos7) I get the following error during the check installation

File "/users/greco/hips.py", line 2, in from hips import WCSGeometry ImportError: cannot import name 'WCSGeometry'

thanks for such effort.

cdeil commented 6 years ago

I think the issue might be that you have named your script /users/greco/hips.py, i.e. the same name as the hips package.

Try renaming to e.g. /users/greco/hips_example.py.

If this doesn't help, what is your version?

python -c 'import hips; print(hips.__version__)'
ggreco77 commented 6 years ago

I did not rename the script; however also using the statement above I get the same issue -> File "", line 1, in File "/users/greco/hips.py", line 2, in from hips import WCSGeometry ImportError: cannot import name 'WCSGeometry'

thanks, giuseppe

cdeil commented 6 years ago

I did not rename the script

Why not? Please try it.

Also, please paste not just part of the traceback, but show everything: the command you ran (probably python hips.py?) and the complete traceback.

ggreco77 commented 6 years ago

ah, ok sorry for misunderstanding -> I rename the script hips.py in hips_example.py in my home dir and I type python3 hips_example.py now the error is different; _Traceback (most recent call last): File "hipsexample.py", line 2, in from hips import WCSGeometry ImportError: bad magic number in 'hips': b'\x03\xf3\r\n'

adl1995 commented 6 years ago

@ggreco77 This is probably because the .pyc files present in the hips repository are damaged. Please try re-installing the package:

$ pip uninstall hips

And then install again:

$ pip install hips --no-deps

Another solution is to manually remove the .pyc files (so Python can generate them again). First cd into the directory where hips is installed. For me, it is:

$ cd /home/adeel/anaconda3/lib/python3.6/site-packages/hips

You can also locate the directory by typing:

$ locate python3.6/site-packages/hips

Finally, delete the .pyc files:

$ find . -name \*.pyc -delete
ggreco77 commented 6 years ago

Many thanks. Now it works fine by removing .pyc files.

cdeil commented 6 years ago

👍