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

NSRangeException on macOS with PyQt6 #229

Open
victorlin opened this issue Feb 10, 2024 · 10 comments
Open

NSRangeException on macOS with PyQt6 #229

victorlin opened this issue Feb 10, 2024 · 10 comments

Comments

@victorlin
Copy link

I just configured Photini with PyQt6 in a conda environment but am not able to click on any of the tabs. This is what happens:

error2

Console output of setup and stack trace
$ micromamba create -n tmp -c conda-forge python=3.8 -y
$ micromamba activate tmp
$ pip3 install photini
$ photini-configure
Which Qt package would you like to use?
  0 PyQt5 [not installed]
  1 PySide2 [not installed]
  2 PyQt6 [not installed]
  3 PySide6 [not installed]
Choose 0/1/2/3 [2]: 2
Would you like to upload pictures to Flickr? (y/n) [y]: n
Would you like to upload pictures to Google Photos? (y/n) [y]: n
Would you like to upload pictures to Ipernity? (y/n) [y]: n
Would you like to upload pictures to Pixelfed or Mastodon? (y/n) [y]: n
Would you like to check spelling of metadata? (y/n) [y]: n
Would you like to import GPS track data? (y/n) [y]: n
Would you like to make higher quality thumbnails? (y/n) [y]: n
Would you like to import pictures from a camera? (y/n) [y]: n
…
Successfully installed PyQt6-6.6.1 PyQt6-Qt6-6.6.1 PyQt6-WebEngine-6.6.0 PyQt6-WebEngine-Qt6-6.6.1 PyQt6-sip-13.6.0

$ photini --version 
No module named 'enchant'
No module named 'gpxpy'
Photini 2024.2.0
  Python 3.8.18 | packaged by conda-forge | (default, Dec 23 2023, 17:25:47) 
[Clang 16.0.6 ]
  python-exiv2 0.16.1, exiv2 0.27.7
  PyQt 6.6.1, Qt 6.6.1, locale en
  ffmpeg version 6.1.1 Copyright (c) 2000-2023 the FFmpeg developers
  available styles: macOS, Windows, Fusion
  using style: macos

$ photini
No module named 'enchant'
No module named 'gpxpy'
No module named 'requests_oauthlib'
No module named 'requests_toolbelt'
No module named 'requests_oauthlib'
No module named 'requests_oauthlib'
qt.qpa.fonts: Populating font family aliases took 75 ms. Replace uses of missing font family "DejaVu Sans" with one that exists to avoid this cost. 
doh set to ""  --  SystemOnly
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndexedSubscript:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(
	0   CoreFoundation                      0x0000000189412800 __exceptionPreprocess + 176
	1   libobjc.A.dylib                     0x0000000188f09eb4 objc_exception_throw + 60
	2   CoreFoundation                      0x0000000189388fc0 -[__NSCFString hasSuffix:] + 0
	3   libqcocoa.dylib                     0x0000000107656044 _ZN20QCocoaSystemTrayIcon13emitActivatedEv + 274796
	4   libqcocoa.dylib                     0x00000001076560c8 _ZN20QCocoaSystemTrayIcon13emitActivatedEv + 274928
	5   libqcocoa.dylib                     0x0000000107654688 _ZN20QCocoaSystemTrayIcon13emitActivatedEv + 268208
	6   QtWidgets                           0x0000000105a311a8 _ZN9QListView16selectionChangedERK14QItemSelectionS2_ + 204
	7   QtCore                              0x0000000101ed348c _ZN11QMetaObject8activateEP7QObjectPKS_iPPv + 3808
	8   QtCore                              0x0000000102099e44 _ZN19QItemSelectionModel20emitSelectionChangedERK14QItemSelectionS2_ + 216
	9   QtCore                              0x0000000102099a2c _ZN19QItemSelectionModel6selectERK14QItemSelection6QFlagsINS_13SelectionFlagEE + 636
	10  QtCore                              0x000000010209970c _ZN19QItemSelectionModel6selectERK11QModelIndex6QFlagsINS_13SelectionFlagEE + 68
	11  QtCore                              0x000000010209a8cc _ZN19QItemSelectionModel15setCurrentIndexERK11QModelIndex6QFlagsINS_13SelectionFlagEE + 260
	12  QtWidgets                           0x000000010588f338 _ZNK9QComboBox5countEv + 828
	13  QtWidgets                           0x00000001058928b4 _ZN9QComboBoxC1ER16QComboBoxPrivateP7QWidget + 2412
	14  QtCore                              0x0000000101ed3224 _ZN11QMetaObject8activateEP7QObjectPKS_iPPv + 3192
	15  QtCore                              0x0000000102082944 _ZN18QAbstractItemModel13endInsertRowsEv + 200
	16  QtGui                               0x0000000104d777a4 _ZN18QStandardItemModel11itemChangedEP13QStandardItem + 2376
	17  QtWidgets                           0x0000000105895910 _ZN9QComboBox10insertItemEiRK5QIconRK7QStringRK8QVariant + 368
	18  QtWidgets.abi3.so                   0x0000000105fe27a0 _ZL22meth_QComboBox_addItemP7_objectS0_S0_ + 256
	19  python3.8                           0x0000000100a9992c cfunction_call_varargs + 288
	20  python3.8                           0x0000000100a9903c _PyObject_MakeTpCall + 744
	21  python3.8                           0x0000000100b878c0 call_function + 612
	22  python3.8                           0x0000000100b83f04 _PyEval_EvalFrameDefault + 27928
	23  python3.8                           0x0000000100a99d68 function_code_fastcall + 128
	24  python3.8                           0x0000000100a99524 PyVectorcall_Call + 120
	25  python3.8                           0x0000000100b841cc _PyEval_EvalFrameDefault + 28640
	26  python3.8                           0x0000000100b7cbd4 _PyEval_EvalCodeWithName + 3040
	27  python3.8                           0x0000000100a99ecc _PyFunction_Vectorcall + 208
	28  python3.8                           0x0000000100a9d2f4 method_vectorcall + 164
	29  python3.8                           0x0000000100b87828 call_function + 460
	30  python3.8                           0x0000000100b83f04 _PyEval_EvalFrameDefault + 27928
	31  python3.8                           0x0000000100a99d68 function_code_fastcall + 128
	32  python3.8                           0x0000000100a99524 PyVectorcall_Call + 120
	33  python3.8                           0x0000000100b841cc _PyEval_EvalFrameDefault + 28640
	34  python3.8                           0x0000000100b7cbd4 _PyEval_EvalCodeWithName + 3040
	35  python3.8                           0x0000000100a99ecc _PyFunction_Vectorcall + 208
	36  python3.8                           0x0000000100a9d45c method_vectorcall + 524
	37  python3.8                           0x0000000100a99524 PyVectorcall_Call + 120
	38  QtCore.abi3.so                      0x0000000101bc23c0 _ZNK8PyQtSlot4callEP7_objectS1_ + 68
	39  QtCore.abi3.so                      0x0000000101bc222c _ZNK8PyQtSlot6invokeEPPvP7_objectS0_b + 296
	40  QtCore.abi3.so                      0x0000000101bc2354 _ZNK8PyQtSlot6invokeEPPvP7_objectS0_ + 16
	41  QtCore.abi3.so                      0x0000000101bc6ed4 _ZL18qt_metacall_workerP17_sipSimpleWrapperP11_typeobjectP11_sipTypeDefN11QMetaObject4CallEiPPv + 632
	42  QtWidgets.abi3.so                   0x0000000105e35950 _ZN14sipQMainWindow11qt_metacallEN11QMetaObject4CallEiPPv + 88
	43  QtCore                              0x0000000101ed31f4 _ZN11QMetaObject8activateEP7QObjectPKS_iPPv + 3144
	44  QtWidgets                           0x0000000105965fc0 _ZN10QTabWidget5clearEv + 972
	45  QtCore                              0x0000000101ed348c _ZN11QMetaObject8activateEP7QObjectPKS_iPPv + 3808
	46  QtWidgets                           0x00000001059493a8 _ZN7QTabBar15setCurrentIndexEi + 440
	47  QtWidgets                           0x000000010594d1c0 _ZN7QTabBar17mouseReleaseEventEP11QMouseEvent + 436
	48  QtWidgets.abi3.so                   0x0000000105de0304 _ZN10sipQTabBar17mouseReleaseEventEP11QMouseEvent + 148
	49  QtWidgets                           0x00000001057c58b8 _ZN7QWidget5eventEP6QEvent + 132
	50  QtWidgets                           0x000000010594b258 _ZN7QTabBar5eventEP6QEvent + 736
	51  QtWidgets.abi3.so                   0x0000000105ddf91c _ZN10sipQTabBar5eventEP6QEvent + 224
	52  QtWidgets                           0x000000010577c594 _ZN19QApplicationPrivate13notify_helperEP7QObjectP6QEvent + 272
	53  QtWidgets                           0x000000010577e5c0 _ZN12QApplication6notifyEP7QObjectP6QEvent + 5072
	54  QtWidgets.abi3.so                   0x0000000105eeb224 _ZN15sipQApplication6notifyEP7QObjectP6QEvent + 248
	55  QtCore                              0x0000000101e89474 _ZN16QCoreApplication15notifyInternal2EP7QObjectP6QEvent + 292
	56  QtWidgets                           0x000000010577cb34 _ZN19QApplicationPrivate14sendMouseEventEP7QWidgetP11QMouseEventS1_S1_PS1_R8QPointerIS0_Ebb + 808
	57  QtWidgets                           0x00000001057da860 _ZNK21QWidgetRepaintManager3rhiEv + 11080
	58  QtWidgets                           0x00000001057d9a6c _ZNK21QWidgetRepaintManager3rhiEv + 7508
	59  QtWidgets                           0x000000010577c594 _ZN19QApplicationPrivate13notify_helperEP7QObjectP6QEvent + 272
	60  QtWidgets                           0x000000010577d3e8 _ZN12QApplication6notifyEP7QObjectP6QEvent + 504
	61  QtWidgets.abi3.so                   0x0000000105eeb224 _ZN15sipQApplication6notifyEP7QObjectP6QEvent + 248
	62  QtCore                              0x0000000101e89474 _ZN16QCoreApplication15notifyInternal2EP7QObjectP6QEvent + 292
	63  QtGui                               0x0000000104ad39ec _ZN22QGuiApplicationPrivate17processMouseEventEPN29QWindowSystemInterfacePrivate10MouseEventE + 1740
	64  QtGui                               0x0000000104b2f674 _ZN22QWindowSystemInterface22sendWindowSystemEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE + 408
	65  libqcocoa.dylib                     0x00000001075f7d74 qt_plugin_instance + 58768
	66  CoreFoundation                      0x000000018939dcfc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 28
	67  CoreFoundation                      0x000000018939dc90 __CFRunLoopDoSource0 + 176
	68  CoreFoundation                      0x000000018939da00 __CFRunLoopDoSources0 + 244
	69  CoreFoundation                      0x000000018939c5f0 __CFRunLoopRun + 828
	70  CoreFoundation                      0x000000018939bc5c CFRunLoopRunSpecific + 608
	71  HIToolbox                           0x0000000193918448 RunCurrentEventLoopInMode + 292
	72  HIToolbox                           0x00000001939180d8 ReceiveNextEventCommon + 220
	73  HIToolbox                           0x0000000193917fdc _BlockUntilNextEventMatchingListInModeWithFilter + 76
	74  AppKit                              0x000000018cb76c54 _DPSNextEvent + 660
	75  AppKit                              0x000000018d34cebc -[NSApplication(NSEventRouting) _nextEve
libc++abi: terminating due to uncaught exception of type NSException
zsh: abort      photini

I'm using macOS 14.1.2 on a M1 Mac mini.

Side note: I first tried using PySide6 but got a segmentation fault before the window was able to appear.

@jim-easterbrook
Copy link
Owner

Thanks for reporting this problem.

I don't have MacOS and have never used conda, so it might be difficult to reproduce the problem. There are some things you could try which might help isolate the cause.

Can you run Photini in a normal Python venv rather then using conda?
Can you run other Qt programs in conda? (Maybe one of the tutorials in https://wiki.python.org/moin/PyQt/Tutorials)

@jim-easterbrook
Copy link
Owner

I've installed micromamba on my Linux box, installed Photini and PyQt6 and it runs OK.

$ photini --version
No module named 'enchant'
No module named 'gpxpy'
Photini 2024.2.0
  Python 3.8.18 | packaged by conda-forge | (default, Dec 23 2023, 17:21:28) 
[GCC 12.3.0]
  python-exiv2 0.16.1, exiv2 0.27.7
  PyQt 6.6.1, Qt 6.6.1, locale en-GB
  ffmpeg version 4.4.4 Copyright (c) 2000-2023 the FFmpeg developers
  available styles: Windows, Fusion
  using style: fusion

@jim-easterbrook
Copy link
Owner

jim-easterbrook commented Feb 11, 2024

Aha! A bit of searching leads me to this: pyqtgraph/pyqtgraph#2896
Can you try installing an earlier version of PyQt6?
pip3 install "pyqt6<6.6" "PyQt6-Qt6<6.6"

PS This probably won't work. PyQt6 is badly packaged and insists on installing subpackages from 6.6 when you try installing older "top" packages.

@jim-easterbrook
Copy link
Owner

The solution is to downgrade each subpackage individually:

$ pip list | grep -i qt
PyQt6               6.6.1
PyQt6-Qt6           6.6.1
PyQt6-sip           13.6.0
PyQt6-WebEngine     6.5.0
PyQt6-WebEngine-Qt6 6.6.1
$ pip3 install PyQt6==6.5.0 PyQt6-WebEngine==6.5.0

Repeat until pip list | grep -i qt only shows version 6.5.0 (except for PyQt6-sip).

@danieltomasz
Copy link

danieltomasz commented Feb 11, 2024

@jim-easterbrook you might want to use PyQt6==6.5.3 in order to support Python 3.12 https://www.riverbankcomputing.com/news/PyQt_v6.5.3_Released

@jim-easterbrook
Copy link
Owner

Fair point, but I just want to establish that it is the PyQt version that is the problem. If any other version can be installed and Photini works with it then we can proceed from there.

@victorlin
Copy link
Author

@jim-easterbrook thanks for the quick response, and good that you found the upstream issue! I just tried PyQT 6.5.0 and it works. photini-configure option 0 (PyQT5) also works fine.

@jim-easterbrook
Copy link
Owner

@victorlin If you can spare the time and effort it would be useful to find out which component(s) of PyQt6 has the problem with v6.6.1 by downgrading each component in turn to v6.6.0 and trying Photini. Then I could specifically exclude v6.6.1 of that component when installing on MacOS.

@victorlin
Copy link
Author

victorlin commented Feb 13, 2024

@jim-easterbrook Sure thing. I did the opposite: start with a working state with everything on version 6.5.0 and check what causes it to break.

  • pip3 install PyQt6==6.6.0 upgrades both PyQt6 and PyQt6-Qt6. This breaks it.

  • pip3 install PyQt6-WebEngine==6.6.0 upgrades both PyQt6-WebEngine and PyQt6-WebEngine-Qt6. This isn't compatible with PyQt<6.6, preventing photini from starting:

    ImportError: dlopen(/Users/victor/.micromamba/envs/tmp/lib/python3.8/site-packages/PyQt6/QtWebEngineWidgets.abi3.so, 0x0002): Symbol not found: _qt_version_tag_6_6
    

I would recommend avoiding versions >=6.6.0 for all PyQt-related packages.

@jim-easterbrook
Copy link
Owner

@jim-easterbrook Sure thing. I did the opposite: start with a working state with everything on version 6.5.0 and check what causes it to break.

* `pip3 install PyQt6==6.6.0` upgrades both `PyQt6` and `PyQt6-Qt6`. This breaks it.

Note that it installs PyQt6-Qt6 6.6.1. That's what I meant by PyQt6 being badly packaged.

* `pip3 install PyQt6-WebEngine==6.6.0` upgrades both `PyQt6-WebEngine` and `PyQt6-WebEngine-Qt6`.

Installing PyQt6-WebEngine==6.6.0 installs PyQt6-WebEngine-Qt6 6.6.1. Downgrading PyQt6-Qt6 or PyQt6-WebEngine-Qt6 or both to 6.6.0 might work.

I would recommend avoiding versions >=6.6.0 for all PyQt-related packages.

I'm assuming 6.6.2 will fix this bug.

jim-easterbrook added a commit that referenced this issue Feb 17, 2024
Hopefully this will deal with bug #229.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants