bitcraze / crazyflie-clients-python

Host applications and library for Crazyflie written in Python.
Other
301 stars 468 forks source link

Client not starting on Mac sonoma #694

Closed ataffanel closed 5 months ago

ataffanel commented 7 months ago

On an apple silicon mac running sonoma (version 14.2.1), with brew on x86 and python 3.11/3.10 the client does not start and stops with this error:

===== 2024.01.24 11:01:10 =====
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/lib/python3.11/site-packages/cfclient/gui.py", line 194, in <module>
    main()
  File "/usr/local/lib/python3.11/site-packages/cfclient/gui.py", line 162, in main
    from .ui.main import MainUI
  File "/usr/local/lib/python3.11/site-packages/cfclient/ui/main.py", line 36, in <module>
    import cfclient.ui.tabs
  File "/usr/local/lib/python3.11/site-packages/cfclient/ui/tabs/__init__.py", line 42, in <module>
    from .locopositioning_tab import LocoPositioningTab
  File "/usr/local/lib/python3.11/site-packages/cfclient/ui/tabs/locopositioning_tab.py", line 52, in <module>
    from vispy import scene
  File "/usr/local/lib/python3.11/site-packages/vispy/__init__.py", line 27, in <module>
    from .util import config, set_log_level, keys, sys_info  # noqa
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/vispy/util/__init__.py", line 14, in <module>
    from . import fonts       # noqa
    ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/vispy/util/fonts/__init__.py", line 13, in <module>
    from ._triage import _load_glyph, list_fonts  # noqa, analysis:ignore
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/vispy/util/fonts/_triage.py", line 14, in <module>
    from ._quartz import _load_glyph, _list_fonts
  File "/usr/local/lib/python3.11/site-packages/vispy/util/fonts/_quartz.py", line 12, in <module>
    from ...ext.cocoapy import cf, ct, quartz, CFRange, CFSTR, CGGlyph, UniChar, \
  File "/usr/local/lib/python3.11/site-packages/vispy/ext/cocoapy.py", line 1288, in <module>
    quartz = cdll.LoadLibrary(util.find_library('quartz'))
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.11/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ctypes/__init__.py", line 454, in LoadLibrary
    return self._dlltype(name)
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/Cellar/python@3.11/3.11.7_1/Frameworks/Python.framework/Versions/3.11/lib/python3.11/ctypes/__init__.py", line 376, in __init__
    self._handle = _dlopen(self._name, mode)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
OSError: dlopen(Quartz.framework/Quartz, 0x0006): tried: 'Quartz.framework/Quartz' (no such file), '/System/Volumes/Preboot/Cryptexes/OSQuartz.framework/Quartz' (no such file), '/usr/local/lib/Quartz.framework/Quartz' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/usr/local/lib/Quartz.framework/Quartz' (no such file), '/usr/lib/Quartz.framework/Quartz' (no such file, not in dyld cache), 'Quartz.framework/Quartz' (no such file)

A quick search online seems point to a problem with OpenGL.

knmcguire commented 6 months ago

A fix was proposed in this discussion: https://github.com/bitcraze/crazyflie-clients-python/issues/694 by @r-bt

One needs to navigate to the package folder of where vispy is installed.

cd /usr/local/lib/python3.11/site-packages/vispy

(change python3.11 with the version you have)

then change the following line in vispy/ext/cocoapy.py

quartz = cdll.LoadLibrary(util.find_library('quartz'))

to

quartz = cdll.LoadLibrary('/System/Library/Frameworks/Quartz.framework/Quartz')

It's not a very nice fix but it works for now until Vispy releases an update for this.

CalvinKoung commented 6 months ago

Hi. why can not navigate to the python3.11 ?

knmcguire commented 6 months ago

That depends on which version pf python you are running the cfclient in. If you have python 3.10 then this is different and you'll need to change it to /python3.10/instead

you can check this in your terminal with python3 --version

knmcguire commented 5 months ago

Also, there is an issue related to this as well on the github vispy repo https://github.com/vispy/vispy/issues/2547

It proposed adding a capitalized Q

util.find_library('Quartz'))

knmcguire commented 5 months ago

And there is a PR open for this now: https://github.com/vispy/vispy/pull/2549

ataffanel commented 5 months ago

Thanks for the links and for the solution! I will be looking at somehow enable this fix in a version of the client (at least we can link setup.py to the fixed branch from the PR).

ataffanel commented 5 months ago

I changed the dependency for vispy to the fixed branch from the vispy PR linked above and it does work!

The fixed branch can be used until vispy merge the PR:

pip install git+https://github.com/bitcraze/crazyflie-clients-python@ataffanel/mac-sonoma-fix
knmcguire commented 5 months ago

just an fyi for if we'd like to merge this branch at one point, this does not affect the windows 11 and ubuntu 22.04 installs