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

python@3.13 fails post-install on x86, cannot load pyexpat, missing dep on expat #206778

Open
4 tasks done
fabioscaccabarozzi opened this issue Feb 6, 2025 · 5 comments
Open
4 tasks done
Labels
15 Sequoia is specifically affected bug Reproducible Homebrew/homebrew-core bug

Comments

@fabioscaccabarozzi
Copy link

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

`brew config`

HOMEBREW_VERSION: 4.4.20
ORIGIN: https://github.com/Homebrew/brew
HEAD: 47ef1a3b0b742a78be35c016df6a0279d6035ebb
Last commit: 3 days ago
Branch: stable
Core tap JSON: 06 Feb 17:28 UTC
Core cask tap JSON: 06 Feb 17:20 UTC
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 12
Homebrew Ruby: 3.3.7 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/3.3.7/bin/ruby
CPU: dodeca-core 64-bit kabylake
Clang: 16.0.0 build 1600
Git: 2.48.1 => /usr/local/bin/git
Curl: 8.7.1 => /usr/bin/curl
macOS: 15.3-x86_64
CLT: 16.2.0.0.1.1733547573
Xcode: 16.2


`brew doctor`

Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Some installed formulae are deprecated or disabled.
You should find replacements for the following formulae:
  node@18
  pidof

Verification

  • My brew doctor output says Your system is ready to brew. and am still able to reproduce my issue.
  • 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.
  • I searched for recent similar issues at https://github.com/Homebrew/homebrew-core/issues?q=is%3Aissue and found no duplicates.

What were you trying to do (and why)?

On a clean x86 system (Mac Mini 2021) with Sequoia 15.3, I had just uninstalled and reinstalled brew from scratch (removed all traces with sudo rm -rf /usr/local).

I ran brew install ansible, which pulls in python@3.13.

What happened (include all command output)?

The formula never post-installed properly.

Investigating in ~/Library/Logs/Homebrew/... showed that the bundled pyexpat (/usr/local/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/lib-dynload/pyexpat.cpython-313-darwin.so) always failed to load.

I tried to run the import at the python3 prompt (from pyexpat import *), and got the same result as the post-install.

What did you expect to happen?

Install ansible without issues.

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

Installing `expat` via `brew install expat` allowed the import to pass, and thus also the post-install.

I guess there's a missing dependency on `expat`?
@fabioscaccabarozzi fabioscaccabarozzi added the bug Reproducible Homebrew/homebrew-core bug label Feb 6, 2025
@utkonos
Copy link
Contributor

utkonos commented Feb 6, 2025

I was just getting my ducks in a row to open this exact same issue. Doing brew install expat does fix this issue.

I see a lot of work around a CVE in libexpat:
python/cpython#126623
I see mention in that issue that expat is bundled, but no mention that Python has unbundled it.

Expat is also mentioned in the what's new:
https://docs.python.org/3/whatsnew/3.13.html#xml

Adding expat as a new dependency certainly quiets the post install failing, but is it the correct change? Can someone suss out if expat is actaully no longer vendored in Python or whether there is some change that was made where the vendored expat is not being detected?

Either way: brew install expat is a good workaround for now.

@SMillerDev
Copy link
Member

As far as I know macOS ships with expat so that seems like a weird dependency

@utkonos
Copy link
Contributor

utkonos commented Feb 6, 2025

There was also a macOS update from 15.2 to 15.3 on 27 Jan 2025. Could that version have changed something? I don't see anything that stands out in the release notes:
https://support.apple.com/en-us/120283
or the security release notes:
https://support.apple.com/en-us/122068

@kkopper
Copy link

kkopper commented Feb 6, 2025

I encountered the same problem while upgrading python@3.13 to version 3.13.2 on a x86 MacBook Pro from 2020 running macOS 15.3. For reference, the output of the postinstall step:

2025-02-06 19:56:43 +0100

/usr/local/Cellar/python@3.13/3.13.2/bin/python3.13
-Im
ensurepip

Traceback (most recent call last):
  File "<string>", line 6, in <module>
    runpy.run_module("pip", run_name="__main__", alter_sys=True)
    ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen runpy>", line 226, in run_module
  File "<frozen runpy>", line 98, in _run_module_code
  File "<frozen runpy>", line 88, in _run_code
  File "/private/tmp/tmpxxxihykv/pip-25.0-py3-none-any.whl/pip/__main__.py", line 24, in <module>
    sys.exit(_main())
             ~~~~~^^
  File "/private/tmp/tmpxxxihykv/pip-25.0-py3-none-any.whl/pip/_internal/cli/main.py", line 78, in main
    command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
  File "/private/tmp/tmpxxxihykv/pip-25.0-py3-none-any.whl/pip/_internal/commands/__init__.py", line 114, in create_command
    module = importlib.import_module(module_path)
  File "/usr/local/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/importlib/__init__.py", line 88, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 1026, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/private/tmp/tmpxxxihykv/pip-25.0-py3-none-any.whl/pip/_internal/commands/install.py", line 19, in <module>
    import pip._internal.self_outdated_check  # noqa: F401
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/private/tmp/tmpxxxihykv/pip-25.0-py3-none-any.whl/pip/_internal/self_outdated_check.py", line 19, in <module>
    from pip._internal.index.package_finder import PackageFinder
  File "/private/tmp/tmpxxxihykv/pip-25.0-py3-none-any.whl/pip/_internal/index/package_finder.py", line 31, in <module>
    from pip._internal.req import InstallRequirement
  File "/private/tmp/tmpxxxihykv/pip-25.0-py3-none-any.whl/pip/_internal/req/__init__.py", line 9, in <module>
    from .req_install import InstallRequirement
  File "/private/tmp/tmpxxxihykv/pip-25.0-py3-none-any.whl/pip/_internal/req/req_install.py", line 40, in <module>
    from pip._internal.operations.install.wheel import install_wheel
  File "/private/tmp/tmpxxxihykv/pip-25.0-py3-none-any.whl/pip/_internal/operations/install/wheel.py", line 40, in <module>
    from pip._vendor.distlib.scripts import ScriptMaker
  File "/private/tmp/tmpxxxihykv/pip-25.0-py3-none-any.whl/pip/_vendor/distlib/scripts.py", line 16, in <module>
    from .compat import sysconfig, detect_encoding, ZipFile
  File "/private/tmp/tmpxxxihykv/pip-25.0-py3-none-any.whl/pip/_vendor/distlib/compat.py", line 81, in <module>
    import xmlrpc.client as xmlrpclib
  File "/usr/local/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/xmlrpc/client.py", line 138, in <module>
    from xml.parsers import expat
  File "/usr/local/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/xml/parsers/expat.py", line 4, in <module>
    from pyexpat import *
ImportError: dlopen(/usr/local/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/lib-dynload/pyexpat.cpython-313-darwin.so, 0x0002): Library not loaded: /usr/local/opt/expat/lib/libexpat.1.dylib
  Referenced from: <448B999F-3FE4-3818-965F-370DFA34122F> /usr/local/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/lib-dynload/pyexpat.cpython-313-darwin.so
  Reason: tried: '/usr/local/opt/expat/lib/libexpat.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/expat/lib/libexpat.1.dylib' (no such file), '/usr/local/opt/expat/lib/libexpat.1.dylib' (no such file)
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/local/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/ensurepip/__main__.py", line 5, in <module>
    sys.exit(ensurepip._main())
             ~~~~~~~~~~~~~~~^^
  File "/usr/local/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/ensurepip/__init__.py", line 257, in _main
    return _bootstrap(
        root=args.root,
    ...<4 lines>...
        default_pip=args.default_pip,
    )
  File "/usr/local/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/ensurepip/__init__.py", line 172, in _bootstrap
    return _run_pip([*args, "pip"], [os.fsdecode(tmp_wheel_path)])
  File "/usr/local/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/ensurepip/__init__.py", line 87, in _run_pip
    return subprocess.run(cmd, check=True).returncode
           ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/subprocess.py", line 579, in run
    raise CalledProcessError(retcode, process.args,
                             output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/usr/local/opt/python@3.13/bin/python3.13', '-I', '-W', 'ignore::DeprecationWarning', '-c', '\nimport runpy\nimport sys\nsys.path = [\'/private/tmp/tmpxxxihykv/pip-25.0-py3-none-any.whl\'] + sys.path\nsys.argv[1:] = [\'install\', \'--no-cache-dir\', \'--no-index\', \'--find-links\', \'/private/tmp/tmpxxxihykv\', \'pip\']\nrunpy.run_module("pip", run_name="__main__", alter_sys=True)\n']' returned non-zero exit status 1.

HOMEBREW_VERSION: 4.4.20
ORIGIN: https://github.com/Homebrew/brew
HEAD: 47ef1a3b0b742a78be35c016df6a0279d6035ebb
Last commit: 3 days ago
Branch: stable
Core tap JSON: 06 Feb 18:14 UTC
Core cask tap JSON: 06 Feb 18:14 UTC
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CASK_OPTS: []
HOMEBREW_DISPLAY: /private/tmp/com.apple.launchd.hIzpDCiwEN/org.xquartz:0
HOMEBREW_MAKE_JOBS: 16
HOMEBREW_NO_BOOTSNAP: set
Homebrew Ruby: 3.3.7 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/3.3.7/bin/ruby
CPU: 16-core 64-bit kabylake
Clang: 16.0.0 build 1600
Git: 2.48.1 => /usr/local/bin/git
Curl: 8.7.1 => /usr/bin/curl
macOS: 15.3-x86_64
CLT: 16.2.0.0.1.1733547573
Xcode: 16.2

HOMEBREW_GIT: git
PATH: /usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/opt/X11/bin:/Library/Apple/usr/bin:/Library/TeX/texbin:/Applications/Wireshark.app/Contents/MacOS:/Library/Frameworks/Mono.framework/Versions/Current/Commands

The important part seems to be the following:

ImportError: dlopen(/usr/local/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/lib-dynload/pyexpat.cpython-313-darwin.so, 0x0002): Library not loaded: /usr/local/opt/expat/lib/libexpat.1.dylib
  Referenced from: <448B999F-3FE4-3818-965F-370DFA34122F> /usr/local/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/lib-dynload/pyexpat.cpython-313-darwin.so
  Reason: tried: '/usr/local/opt/expat/lib/libexpat.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/opt/expat/lib/libexpat.1.dylib' (no such file), '/usr/local/opt/expat/lib/libexpat.1.dylib' (no such file)

@cho-m cho-m added the 15 Sequoia is specifically affected label Feb 6, 2025
@gedge
Copy link

gedge commented Feb 7, 2025

similar fail, but no mention of expat (I later installed brew's expat and re-ran and all was fine):

==> Upgrading python@3.13
  3.13.1 -> 3.13.2
==> Pouring python@3.13--3.13.2.sonoma.bottle.tar.gz
==> /usr/local/Cellar/python@3.13/3.13.2/bin/python3.13 -Im ensurepip
Last 15 lines from /Users/xxx/Library/Logs/Homebrew/python@3.13/post_install.01.python3.13:
  File "/usr/local/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/ensurepip/__init__.py", line 257, in _main
    return _bootstrap(
        root=args.root,
    ...<4 lines>...
        default_pip=args.default_pip,
    )
  File "/usr/local/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/ensurepip/__init__.py", line 172, in _bootstrap
    return _run_pip([*args, "pip"], [os.fsdecode(tmp_wheel_path)])
  File "/usr/local/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/ensurepip/__init__.py", line 87, in _run_pip
    return subprocess.run(cmd, check=True).returncode
           ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.13/3.13.2/Frameworks/Python.framework/Versions/3.13/lib/python3.13/subprocess.py", line 579, in run
    raise CalledProcessError(retcode, process.args,
                             output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['/usr/local/opt/python@3.13/bin/python3.13', '-I', '-W', 'ignore::DeprecationWarning', '-c', '\nimport runpy\nimport sys\nsys.path = [\'/private/tmp/tmpxkntto/pip-25.0-py3-none-any.whl\'] + sys.path\nsys.argv[1:] = [\'install\', \'--no-cache-dir\', \'--no-index\', \'--find-links\', \'/private/tmp/tmpxkntto\', \'pip\']\nrunpy.run_module("pip", run_name="__main__", alter_sys=True)\n']' returned non-zero exit status 1.
Warning: The post-install step did not complete successfully
You can try again using:
  brew postinstall python@3.13
Warning: Removed Sorbet lines from backtrace!
Rerun with `--verbose` to see the original backtrace
==> Summary
🍺  /usr/local/Cellar/python@3.13/3.13.2: 3,246 files, 60.9MB

For completeness, brew config:

HOMEBREW_VERSION: 4.4.20-79-g91acde3
ORIGIN: https://github.com/Homebrew/brew
HEAD: 91acde379dafc6a2d52f42732b1bf617ef0bd67d
Last commit: 8 hours ago
Branch: master
Core tap HEAD: 0c9a9112b063961b83eaaf03417c53df53c0e16c
Core tap last commit: 11 minutes ago
Core tap JSON: 07 Feb 07:11 UTC
Core cask tap HEAD: 4905781f496b91e1f534ac1d52f07403b090be6e
Core cask tap last commit: 9 minutes ago
Core cask tap JSON: 07 Feb 07:11 UTC
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CASK_OPTS: []
HOMEBREW_EDITOR: vim
HOMEBREW_MAKE_JOBS: 16
HOMEBREW_SORBET_RUNTIME: set
Homebrew Ruby: 3.3.7 => /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/3.3.7/bin/ruby
CPU: 16-core 64-bit kabylake
Clang: 16.0.0 build 1600
Git: 2.48.1 => /usr/local/bin/git
Curl: 8.7.1 => /usr/bin/curl
macOS: 15.3-x86_64
CLT: 16.2.0.0.1.1733547573
Xcode: 16.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
15 Sequoia is specifically affected bug Reproducible Homebrew/homebrew-core bug
Projects
None yet
Development

No branches or pull requests

6 participants