dstndstn / astrometry.net

Astrometry.net -- automatic recognition of astronomical images
http://astrometry.net
Other
662 stars 186 forks source link

Cannot import astrometry.util.util #199

Closed gvnnlgl closed 3 years ago

gvnnlgl commented 3 years ago

In a raspbian buster environment, I compiled 0.80 to default /usr/local/astrometry; all suggested libraries installed with apt. Solving and plotting ok with solve-field, but I would need to use the util in python. util.py is giving error because _util is not found, although there is _util.cpython-37m-arm-linux-gnueabihf.so file for it in /usr/local/astrometry/lib/python/astrometry/util Is there something I need to do while making?

dstndstn commented 3 years ago

Hi, Have you added to your PYTHONPATH? eg,

export PYTHONPATH=${PYTHONPATH}:/usr/local/astrometry/lib/python

? One additional note, you should not be in the astrometry/ source directory when you try to import, because there is an 'astrometry' symlink there that python will treat as the package. So try,

export PYTHONPATH=${PYTHONPATH}:/usr/local/astrometry/lib/python cd /tmp python3 -c "import astrometry; print(astrometry.file); print(astrometry.version)" python3 -c "import astrometry.util; print(astrometry.util.file)" python3 -c "import astrometry.util.util; print(astrometry.util.util.file)"

thanks

dstndstn commented 3 years ago

ps, we have an ubuntu 18 build in our CI, if that's of any help. https://app.circleci.com/pipelines/github/dstndstn/astrometry.net?branch=master

gvnnlgl commented 3 years ago

Thanks for quick reply! Here is result of proposed test, if it looks ok I will try later if this can solve the issue

...:$ python3 -c "import astrometry; print(astrometry.file); print(astrometry.version)" /usr/local/astrometry/lib/python/astrometry/init.py 0.80

...:$ python3 -c "import astrometry.util; print(astrometry.util.file)" /usr/local/astrometry/lib/python/astrometry/util/init.py

...:$ python3 -c "import astrometry.util.util; print(astrometry.util.util.file)" /usr/local/astrometry/lib/python/astrometry/util/util.py

gvnnlgl commented 3 years ago

(of course by replacing bold font with double underscores)

gvnnlgl commented 3 years ago

Thanks for your time, I noted that in your test snippet you used python3 and I questioned myself about the version my system was using by default: in fact it was 2.7! So I started my webapp (made in flask) by using python3 command and now it is importing astrometry.util.util... In closing the issue, I report the result of test snippet with "python" instead of "python3" if it may be useful for others:

...:$ python -c "import astrometry.util.util; print(astrometry.util.util.file)" ImportError: /usr/local/astrometry/lib/python/astrometry/util/_util.cpython-37m-arm-linux-gnueabihf.so: undefined symbol: PyBytes_AsStringAndSize

dstndstn commented 3 years ago

Aha! Good sleuthing. Thanks for leaving answers for the future 👍