ronaldoussoren / pyobjc

The Python <-> Objective-C Bridge with bindings for macOS frameworks
https://pyobjc.readthedocs.io
577 stars 48 forks source link

RuntimeError: Wrong struct-size of PyObjC C API (got 288, expected 296) #630

Open nn646 opened 2 days ago

nn646 commented 2 days ago

Describe the bug I tried to import Vision and it does not work The error I got is: RuntimeError: Wrong struct-size of PyObjC C API (got 288, expected 296)

Platform information

To Reproduce In the Anaconda navigator, I launched the JupyterLab and opened a notebook in a cloud folder. In the JypterLab terminal, I ran pip install pyobjc-framework-Vision; pip show pyobjc-framework-Vision showed that the installed packages are located in the folder "/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages"

In the notebook again, I ran

sys.path.append("/Library/Frameworks/Python.framework/Versions/3.12/lib/python3.12/site-packages")
import Cocoa
import objc
import Vision
from Cocoa import NSURL

and the error occurs. Expected behavior I expected the package to be imported.

Additional context I tried to run the code described here: https://gist.github.com/jonashaag/95e8b75ed44cc5b93cbc5d4599e3803a _v1 function worked and _v2 did not

The full error message are as below:

截圖 2024-12-01 12 32 17 截圖 2024-12-01 12 32 30 截圖 2024-12-01 12 32 37
Jdbeck66 commented 1 day ago

Similar, When trying to run jupyter lab

jupyter lab
Traceback (most recent call last):
  File "/opt/homebrew/Caskroom/miniforge/base/bin/jupyter-lab", line 6, in <module>
    from jupyterlab.labapp import main
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/jupyterlab/__init__.py", line 8, in <module>
    from .handlers.announcements import (
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/jupyterlab/handlers/announcements.py", line 15, in <module>
    from jupyterlab_server.translation_utils import translator
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/jupyterlab_server/__init__.py", line 6, in <module>
    from .app import LabServerApp
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/jupyterlab_server/app.py", line 10, in <module>
    from jupyter_server.extension.application import ExtensionApp, ExtensionAppJinjaMixin
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/jupyter_server/extension/application.py", line 17, in <module>
    from jupyter_server.serverapp import ServerApp
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/jupyter_server/serverapp.py", line 114, in <module>
    from jupyter_server.services.contents.filemanager import (
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/jupyter_server/services/contents/filemanager.py", line 25, in <module>
    from send2trash import send2trash
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/send2trash/__init__.py", line 12, in <module>
    from send2trash.mac import send2trash
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/send2trash/mac/__init__.py", line 14, in <module>
    from send2trash.mac.modern import send2trash
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/send2trash/mac/modern.py", line 7, in <module>
    from Foundation import NSFileManager, NSURL
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/Foundation/__init__.py", line 9, in <module>
    import CoreFoundation
  File "/opt/homebrew/Caskroom/miniforge/base/lib/python3.10/site-packages/CoreFoundation/__init__.py", line 28, in <module>
    import CoreFoundation._CoreFoundation  # isort:skip  # noqa: E402
RuntimeError: Wrong version of PyObjC C API (got 25, expected 21)

MacbookPro M1 running Sequoia 15.1.1

mamba list pyobjc
List of packages in environment: "/opt/homebrew/Caskroom/miniforge/base"

  Name                    Version  Build            Channel    
─────────────────────────────────────────────────────────────────
  pyobjc-core             10.3.2   py310h4e4eb3c_0  conda-forge
  pyobjc-framework-cocoa  7.3      py310hbe9552e_1  conda-forge