salsergey / QCustomPlot-PyQt

Bindings for graphics lib QCustomPlot for PyQt5 and PyQt6
MIT License
9 stars 1 forks source link

Mac / Installing QCustomPlot_PyQt5 error #10

Open therobinojones opened 1 month ago

therobinojones commented 1 month ago

When trying to install ‘QCustomPlot_PyQt5’ to my environment It’s always crashing with the error below:

installing with pip like this > pip install QCustomPlot_PyQt5

Not sure why it’s looking for pyqt6 when installing QCustomPlot_PyQt5? I installed pyqt6 but same exact error.

I also tried compiling a version using the information on this github but it throws a pyqt6 error as well

(RobinoScanEnv) user@MacStudio QCustomPlot-PyQt % pip install QCustomPlot_PyQt5 
Collecting QCustomPlot_PyQt5
  Using cached QCustomPlot_PyQt5-2.1.1.2.tar.gz (487 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [19 lines of output]
      Querying qmake about your Qt installation...

      Using Python version 3.10.14.
      Traceback (most recent call last):
        File "/Users/user/Documents/Python/Project/RobinoScanEnv/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
          main()
        File "/Users/user/Documents/Python/Project/RobinoScanEnv/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
        File "/Users/user/Documents/Python/Project/RobinoScanEnv/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 152, in prepare_metadata_for_build_wheel
          whl_basename = backend.build_wheel(metadata_directory, config_settings)
        File "/private/var/folders/3z/random_path/T/pip-build-env-abc123/overlay/lib/python3.10/site-packages/sipbuild/api.py", line 46, in build_wheel
          project = AbstractProject.bootstrap('wheel',
        File "/private/var/folders/3z/random_path/T/pip-build-env-abc123/overlay/lib/python3.10/site-packages/sipbuild/abstract_project.py", line 92, in bootstrap
          project.setup(pyproject, tool, tool_description)
        File "/private/var/folders/3z/random_path/T/pip-build-env-abc123/overlay/lib/python3.10/site-packages/sipbuild/project.py", line 603, in setup
          self.update(tool)
        File "/private/var/folders/3z/random_path/T/pip-install-xyz789/qcustomplot-pyqt5_123456789/project.py", line 41, in update
          import PyQt6 as PyQt
      ModuleNotFoundError: No module named 'PyQt6'
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
salsergey commented 1 month ago

It seems that your default qmake is for Qt6. As a result my script tries to build PyQt5 module using PyQt6. This script should be reworked in future. For now, you can use sip-build/sip-wheel commands with the option --qmake _path_to_qmake5_. Also there is some bug in sip resulting in error while cleaning build directory. However, wheel file should be created in local directory despite the error message.

therobinojones commented 1 month ago

I was able to compile the wheel and install it thank you very much!

However my program is throwing errors and crashes :(

objc[13251]: Class QMacAutoReleasePoolTracker is implemented in both /Users/35mm/.pyenv/versions/3.10.14/envs/RobinoScanEnv/lib/python3.10/site-packages/PyQt5/Qt5/lib/QtCore.framework/Versions/5/QtCore (0x1032b1230) and /opt/homebrew/Cellar/qt@5/5.15.13_1/lib/QtCore.framework/Versions/5/QtCore (0x1129e92e8). One of the two will be used. Which one is undefined. objc[13251]: Class QT_ROOT_LEVEL_POOL__THESE_OBJECTS_WILL_BE_RELEASED_WHEN_QAPP_GOES_OUT_OF_SCOPE is implemented in both /Users/35mm/.pyenv/versions/3.10.14/envs/RobinoScanEnv/lib/python3.10/site-packages/PyQt5/Qt5/lib/QtCore.framework/Versions/5/QtCore (0x1032b12a8) and /opt/homebrew/Cellar/qt@5/5.15.13_1/lib/QtCore.framework/Versions/5/QtCore (0x1129e9360). One of the two will be used. Which one is undefined. objc[13251]: Class KeyValueObserver is implemented in both /Users/35mm/.pyenv/versions/3.10.14/envs/RobinoScanEnv/lib/python3.10/site-packages/PyQt5/Qt5/lib/QtCore.framework/Versions/5/QtCore (0x1032b12d0) and /opt/homebrew/Cellar/qt@5/5.15.13_1/lib/QtCore.framework/Versions/5/QtCore (0x1129e9388). One of the two will be used. Which one is undefined. objc[13251]: Class RunLoopModeTracker is implemented in both /Users/35mm/.pyenv/versions/3.10.14/envs/RobinoScanEnv/lib/python3.10/site-packages/PyQt5/Qt5/lib/QtCore.framework/Versions/5/QtCore (0x1032b1320) and /opt/homebrew/Cellar/qt@5/5.15.13_1/lib/QtCore.framework/Versions/5/QtCore (0x1129e93d8). One of the two will be used. Which one is undefined. objc[13251]: Class QCocoaPageLayoutDelegate is implemented in both /opt/homebrew/Cellar/qt@5/5.15.13_1/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport (0x10128d168) and /Users/35mm/.pyenv/versions/3.10.14/envs/RobinoScanEnv/lib/python3.10/site-packages/PyQt5/Qt5/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport (0x167291178). One of the two will be used. Which one is undefined. objc[13251]: Class QCocoaPrintPanelDelegate is implemented in both /opt/homebrew/Cellar/qt@5/5.15.13_1/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport (0x10128d1e0) and /Users/35mm/.pyenv/versions/3.10.14/envs/RobinoScanEnv/lib/python3.10/site-packages/PyQt5/Qt5/lib/QtPrintSupport.framework/Versions/5/QtPrintSupport (0x1672911f0). One of the two will be used. Which one is undefined. QWidget: Must construct a QApplication before a QWidget zsh: abort /Users/35mm/.pyenv/versions/3.10.14/envs/RobinoScanEnv/bin/python

salsergey commented 1 month ago

Regarding multiple versions of Qt5, I'm not sure if it is an error or just a warning. Seems you have a system Qt5 library and also the one distributed with PyQt5. Maybe one of them is not needed?

The last message is definitely an error: Must construct a QApplication before a QWidget. It could be something wrong with your code. You should create QApplication before other Qt widgets. Have a look at the example here.

therobinojones commented 1 month ago

Thanks very much for all the information and your help.

About my code, it runs fine on Windows with no 'Qapplication before other QT Widgets' error but on Mac, the same exact code but with the custom compiled version of QCustomPlot - it crashes with the error above.

Do you think it's still my code even if it runs fine on Windows?

salsergey commented 1 month ago

I have no experience with Mac, so I can't say if something could be different here. However, in PyQt, as well as in Qt, QApplication should be created first. I'd suggest you to make sure that QApplication is created before (if it isn't) and see if it helps. Also you have other errors about multiple Qt5 versions. It could be that these errors are somehow the reason of all the problems.