cortex-lab / phy

phy: interactive visualization and manual spike sorting of large-scale ephys data
BSD 3-Clause "New" or "Revised" License
304 stars 155 forks source link

ImportError on macOS: library not loaded: @rpath/QtCore.framework/Versions/5/QtCore #1226

Closed anna-teruel closed 1 month ago

anna-teruel commented 8 months ago

Hey everyone!

I'm trying to install phy on my macOS M1 Sonoma 14.0, but I fail to run phy template-gui params.py. I am aware that phy is not yet supported for arm-64 architecture. I created an environment using miniconda macOS-14.0-x86_64-i386-64bit, and installed phy inside that environment, following the instructions provided on the Readme file. The error I get is the following:

(phy2) annateruel@MacBook-MacBook-Pro-de-Anna PyQt5 % phy template-gui params.py Traceback (most recent call last): File "/Users/annateruel/minicondax86/envs/phy2/bin/phy", line 5, in <module> from phy.apps import phycli File "/Users/annateruel/minicondax86/envs/phy2/lib/python3.11/site-packages/phy/apps/__init__.py", line 22, in <module> from phy.gui.qt import QtDialogLogger File "/Users/annateruel/minicondax86/envs/phy2/lib/python3.11/site-packages/phy/gui/__init__.py", line 6, in <module> from .qt import ( File "/Users/annateruel/minicondax86/envs/phy2/lib/python3.11/site-packages/phy/gui/qt.py", line 33, in <module> from PyQt5.QtCore import (Qt, QByteArray, QMetaObject, QObject, # noqa ImportError: dlopen(/Users/annateruel/minicondax86/envs/phy2/lib/python3.11/site-packages/PyQt5/QtCore.abi3.so, 0x0002): Library not loaded: @rpath/QtCore.framework/Versions/5/QtCore Referenced from: <1164C5D2-6562-35CA-9546-488193326D7A> /Users/annateruel/minicondax86/envs/phy2/lib/python3.11/site-packages/PyQt5/QtCore.abi3.so Reason: tried: '/Users/annateruel/minicondax86/envs/phy2/lib/python3.11/site-packages/PyQt5/Qt5/lib/QtCore.framework/Versions/5/QtCore' (no such file), '/Users/annateruel/minicondax86/envs/phy2/lib/python3.11/site-packages/PyQt5/Qt5/lib/QtCore.framework/Versions/5/QtCore' (no such file), '/Users/annateruel/minicondax86/envs/phy2/bin/../lib/QtCore.framework/Versions/5/QtCore' (no such file), '/Users/annateruel/minicondax86/envs/phy2/bin/../lib/QtCore.framework/Versions/5/QtCore' (no such file), '/Library/Frameworks/QtCore.framework/Versions/5/QtCore' (no such file), '/System/Library/Frameworks/QtCore.framework/Versions/5/QtCore' (no such file, not in dyld cache)

Indeed, the error is in PyQt5.QtCore, because somehow it doesn't find some paths. I have tried to reach those paths and I get a permission error. Only can enter if sudo -s. But still, some of the paths mentioned don't exist. Thus, I don't know what to do. Guess I am missing the installation of some packages.

In my environment here's the list of packages installed and their corresponding version, just in case it is helpful. Package Version


appnope 0.1.3 asttokens 2.4.0 backcall 0.2.0 backports.functools-lru-cache 1.6.5 bokeh 3.3.0 Brotli 1.1.0 cached-property 1.5.2 certifi 2023.7.22 charset-normalizer 3.3.0 click 8.1.7 cloudpickle 3.0.0 colorama 0.4.6 colorcet 3.0.1 comm 0.1.4 contourpy 1.1.1 cycler 0.12.1 Cython 3.0.4 cytoolz 0.12.2 dask 2023.10.0 debugpy 1.8.0 decorator 5.1.1 distributed 2023.10.0 exceptiongroup 1.1.3 executing 1.2.0 fonttools 4.43.1 fsspec 2023.9.2 ghp-import 2.1.0 h5py 3.10.0 idna 3.4 importlib-metadata 6.8.0 iniconfig 2.0.0 ipykernel 6.25.2 ipython 8.16.1 ipython-genutils 0.2.0 jedi 0.19.1 Jinja2 3.1.2 joblib 1.3.2 jupyter_client 8.4.0 jupyter_core 5.4.0 kiwisolver 1.4.5 klusta 3.0.16 klustakwik2 0.2.6 locket 1.0.0 lz4 4.3.2 Markdown 3.5 MarkupSafe 2.1.3 matplotlib 3.8.0 matplotlib-inline 0.1.6 mergedeep 1.3.4 mkdocs 1.5.3 msgpack 1.0.6 mtscomp 1.0.2 munkres 1.1.4 nest-asyncio 1.5.8 numpy 1.26.0 packaging 23.2 pandas 2.1.1 param 1.13.0 parso 0.8.3 partd 1.4.1 pathspec 0.11.2 pexpect 4.8.0 phy 2.0b5 phylib 2.4.3 pickleshare 0.7.5 Pillow 9.4.0 pip 23.3 platformdirs 3.11.0 pluggy 1.3.0 ply 3.11 prompt-toolkit 3.0.39 psutil 5.9.5 ptyprocess 0.7.0 pure-eval 0.2.2 pyarrow 13.0.0 pyct 0.5.0 Pygments 2.16.1 PyOpenGL 3.1.6 pyparsing 3.1.1 PyQt5 5.15.10 PyQt5-Qt5 5.15.11 PyQt5-sip 12.13.0 PyQtWebEngine 5.15.6 PyQtWebEngine-Qt5 5.15.2 PySocks 1.7.1 pytest 7.4.2 python-dateutil 2.8.2 pytz 2023.3.post1 PyYAML 6.0.1 pyyaml_env_tag 0.1 pyzmq 25.1.1 qtconsole 5.4.4 QtPy 2.4.0 requests 2.31.0 responses 0.23.2 scikit-learn 1.3.1 scipy 1.11.3 setuptools 68.2.2 sip 6.6.2 six 1.16.0 sortedcontainers 2.4.0 stack-data 0.6.2 tblib 2.0.0 threadpoolctl 3.2.0 toml 0.10.2 tomli 2.0.1 toolz 0.12.0 tornado 6.3.3 tqdm 4.66.1 traitlets 5.11.2 types-PyYAML 6.0.12.12 typing_extensions 4.8.0 tzdata 2023.3 urllib3 2.0.7 watchdog 3.0.0 wcwidth 0.2.8 wheel 0.41.2 xyzservices 2023.10.0 zict 3.0.0 zipp 3.17.0

Any help would be more than welcome. I've tried to install phy on different macOs with intel architecture and the error I get is the same. Then I guess is not related to my macOS M1. If you need any further information I'll provide it.

Thanks in advance!

zm711 commented 8 months ago

@anna-teruel, the instructions have been updated. Not sure if this will fix the M architecture issue, but the new installation instructions do not involve installing phy from pypi. Have you tried:

conda env create -f environment.yml
conda activate phy2

This should make sure that all the packages are the correct up-to-date packages. If you have already done this, then this could be a mac permission issue, but you'd probably have to search around on PyQt5 to see how they suggestion dealing with M* chip Macs.

anna-teruel commented 8 months ago

Thanks @zm711 !!! 👍

It worked now, more or less. So with new config file I can successfully open the GUI. However everything looks blank (please find picture attached). So I cannot see the amplitude viewer, correlogram etc.

Any idea what is missing? Thanks for your time! Captura de pantalla 2023-11-02 a les 17 25 03 (2)

By the way, the default environment.yml doesn't exactly work due to python version. In the yml I had to change python version =3.11 because by default it uses python 3.12 which doesn't support 'imp'.

phy template-gui params.py Traceback (most recent call last): File "/opt/homebrew/Caskroom/miniconda/base/envs/phy2/bin/phy", line 5, in <module> from phy.apps import phycli File "/opt/homebrew/Caskroom/miniconda/base/envs/phy2/lib/python3.12/site-packages/phy/__init__.py", line 21, in <module> from .utils.config import load_master_config File "/opt/homebrew/Caskroom/miniconda/base/envs/phy2/lib/python3.12/site-packages/phy/utils/__init__.py", line 8, in <module> from .plugin import IPlugin, attach_plugins File "/opt/homebrew/Caskroom/miniconda/base/envs/phy2/lib/python3.12/site-packages/phy/utils/plugin.py", line 14, in <module> import imp ModuleNotFoundError: No module named 'imp'

zm711 commented 8 months ago

@anna-teruel,

Yeah that change just happened unfortunately (Python 3.12). I'll see if I can fix the imp for future users, and if not I will update the yaml.

Could you run

phy template-gui params.py --debug #edit for your file path for params.py

Then copy the output here. That will say what stage of the gui generation is failing so we can try to troubleshoot what is going wrong.

anna-teruel commented 8 months ago

Thanks for the quick response @zm711 👍

Please, find attached the output I get (sorry, it's long). output.txt

zm711 commented 8 months ago

@anna-teruel,

so bad news and this is what I was afraid of. openGL is deprecated on macs. I'm linking to a reddit discussion here

So unless you're willing to try to mess around with stuff and really play with the version it is probably actually best to use Phy on Windows or Linux.

The gui itself is working (which is why you have empty boxes), but openGL is used to actually do the graphics rendering. The errors that you are getting are indicating that openGL is failing on your mac, which is a known issue.

Sorry! But since macOS is switching over to Vulkan and this package is currently more maintenance rather than active development I don't think this will be fixed for Macs anytime soon.