Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

astrometry-net: unable to import python utilities associated with the astrometry.net code base #116710

Closed
2 tasks done
moustakas opened this issue Nov 25, 2022 · 2 comments
Closed
2 tasks done
Labels
outdated PR was locked due to age

Comments

@moustakas
Copy link

brew gist-logs <formula> link OR brew config AND brew doctor output

% brew config
HOMEBREW_VERSION: 3.6.12
ORIGIN: https://github.com/Homebrew/brew
HEAD: 759ab2d0bdc6b0d1f810d6e9351c834d027809f7
Last commit: 7 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 6db06c4bf6e92698ecaa7815f7e9b03fcfd50b9c
Core tap last commit: 5 minutes ago
Core tap branch: master
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_EDITOR: emacs
HOMEBREW_MAKE_JOBS: 10
Homebrew Ruby: 2.6.8 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: 10-core 64-bit arm_firestorm_icestorm
Clang: 14.0.0 build 1400
Git: 2.38.1 => /opt/homebrew/bin/git
Curl: 7.79.1 => /usr/bin/curl
macOS: 12.6-arm64
CLT: 14.1.0.0.1.1666437224
Xcode: 14.1
Rosetta 2: false

% brew doctor
Your system is ready to brew.

% brew info astrometry-net
==> astrometry-net: stable 0.91 (bottled)
Automatic identification of astronomical images
https://github.com/dstndstn/astrometry.net
/opt/homebrew/Cellar/astrometry-net/0.91 (1,100 files, 36.7MB) *
  Poured from bottle on 2022-11-25 at 12:55:16
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/astrometry-net.rb
License: BSD-3-Clause
==> Dependencies
Build: pkg-config ✔, swig ✔
Required: cairo ✔, cfitsio ✔, gsl ✔, jpeg-turbo ✔, libpng ✔, netpbm ✔, numpy ✔, python@3.11 ✔, wcslib ✔
==> Analytics
install: 150 (30 days), 331 (90 days), 1,335 (365 days)
install-on-request: 150 (30 days), 332 (90 days), 1,336 (365 days)
build-error: 0 (30 days)

% brew info python
==> python@3.10: stable 3.10.8 (bottled)
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/opt/homebrew/Cellar/python@3.10/3.10.8 (3,133 files, 57.5MB) *
  Poured from bottle on 2022-11-24 at 08:57:23
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/python@3.10.rb
License: Python-2.0
==> Dependencies
Build: pkg-config ✔
Required: gdbm ✔, mpdecimal ✔, openssl@1.1 ✔, readline ✔, sqlite ✔, xz ✔
==> Caveats
Python has been installed as
  /opt/homebrew/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /opt/homebrew/opt/python@3.10/libexec/bin

You can install Python packages with
  pip3 install <package>
They will install into the site-package directory
  /opt/homebrew/lib/python3.10/site-packages

tkinter is no longer included with this formula, but it is available separately:
  brew install python-tk@3.10

See: https://docs.brew.sh/Homebrew-and-Python
==> Analytics
install: 560,723 (30 days), 2,177,411 (90 days), 5,700,260 (365 days)
install-on-request: 300,743 (30 days), 978,463 (90 days), 1,852,726 (365 days)
build-error: 336 (30 days)

Verification

  • I ran brew update and am still able to reproduce my issue.
  • I have resolved all warnings from brew doctor and that did not fix my problem.

What were you trying to do (and why)?

The homebrew formula for astrometry.net is wonderful in that it successfully installs all the executables typically needed by this software package. However, I would also like to use some of the associated Python code, but there appears to be a problem when the higher-level Python utilities try to import the shared library which contains the lower-level (compiled) C code.

In addition, I get a "circular import" error when trying to import one of the (Python) dependencies, fitsio, which should also not occur.

What happened (include all command output)?

First, add the astrometry.net Python libraries to PYTHONPATH

export PYTHONPATH=/opt/homebrew/Cellar/astrometry-net/0.91/libexec/lib/python3.11/site-packages

and then try a simple import of some of the utilities:

/opt/homebrew/bin/python3 -c "from astrometry.util import util"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/homebrew/Cellar/astrometry-net/0.91/libexec/lib/python3.11/site-packages/astrometry/util/util.py", line 13, in <module>
    from . import _util
ImportError: cannot import name '_util' from 'astrometry.util' (/opt/homebrew/Cellar/astrometry-net/0.91/libexec/lib/python3.11/site-packages/astrometry/util/__init__.py)

And probably unrelated, I get a "circular import" error when trying to import one of the code's Python dependencies, fitsio. (This error, however, is secondary for my work and not as important as not being able to import the astrometry.net Python utilities.)

/opt/homebrew/bin/python3 -c "import fitsio"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/homebrew/Cellar/astrometry-net/0.91/libexec/lib/python3.11/site-packages/fitsio/__init__.py", line 10, in <module>
    from . import fitslib
  File "/opt/homebrew/Cellar/astrometry-net/0.91/libexec/lib/python3.11/site-packages/fitsio/fitslib.py", line 27, in <module>
    from . import _fitsio_wrap
ImportError: cannot import name '_fitsio_wrap' from partially initialized module 'fitsio' (most likely due to a circular import) (/opt/homebrew/Cellar/astrometry-net/0.91/libexec/lib/python3.11/site-packages/fitsio/__init__.py)

What did you expect to happen?

I should have been able to import either the astrometry.util.util or fitsio modules without error (i.e., with no Traceback on the command line).

Step-by-step reproduction instructions (by running brew commands)

brew install python
brew install astrometry-net
export PYTHONPATH=/opt/homebrew/Cellar/astrometry-net/0.91/libexec/lib/python3.11/site-packages
/opt/homebrew/bin/python3 -c "from astrometry.util import util"
/opt/homebrew/bin/python3 -c "import fitsio"
@moustakas moustakas added the bug Reproducible Homebrew/homebrew-core bug label Nov 25, 2022
@cho-m
Copy link
Member

cho-m commented Nov 28, 2022

When using a formula's python bindings, you will need to use the matching version of Python that is specified by formula, e.g.

% brew info astrometry-net
...
Required: cairo ✔, cfitsio ✔, gsl ✔, jpeg-turbo ✔, libpng ✔, netpbm ✔, numpy ✔, python@3.11 ✔, wcslib ✔

vs.

% brew info python
==> python@3.10: stable 3.10.8 (bottled)

We have not yet migrated python alias to point to python@3.11 (see #114154).

Until then, you will want to use /opt/homebrew/bin/python3.11 or /opt/homebrew/opt/python@3.11/libexec/bin/python3

@cho-m cho-m removed the bug Reproducible Homebrew/homebrew-core bug label Dec 8, 2022
@moustakas
Copy link
Author

Thank you @cho-m, this fixed my issue and makes perfect sense. I appreciate the prompt response.

@github-actions github-actions bot added the outdated PR was locked due to age label Jan 8, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

No branches or pull requests

2 participants