portugueslab / stytra

A modular package to control stimulation and track behaviour
http://www.portugueslab.com/stytra/
GNU General Public License v3.0
41 stars 26 forks source link

Installation issues, PyQt is the prime suspect #96

Open francoiskroll opened 3 months ago

francoiskroll commented 3 months ago

Thank you for the impressive work!

I am on a MacBook M2. I followed religiously the installation instructions:

conda env create -f ~/.../environment.yml # edited to create environment 'stytra', not 'stytra_env'
conda activate stytra
pip install stytra

But running python -m stytra.examples.looming_exp crashes:

ImportError: dlopen(/Users/francoiskroll/miniconda3/envs/stytra/lib/python3.12/site-packages/PyQt5/QtCore.abi3.so, 0x0002): Library not loaded: @rpath/QtCore.framework/Versions/5/QtCore etc.

I did notice pip install stytra does suspicious things around PyQt, like:

Attempting uninstall: PyQt5-sip Found existing installation: PyQt5-sip 12.12.2 Uninstalling PyQt5-sip-12.12.2: Successfully uninstalled PyQt5-sip-12.12.2

But well, it concludes

Successfully installed [...] PyQt5-5.15.10 PyQt5-Qt5-5.15.12 PyQt5-sip-12.13.0 [...]

And all seems present if I run conda list:

[...] pyqt 5.15.9 py312h550cae4_5 conda-forge pyqt5 5.15.10 pypi_0 pypi pyqt5-qt5 5.15.12 pypi_0 pypi pyqt5-sip 12.13.0 pypi_0 pypi pyqtgraph 0.13.4 pypi_0 pypi [...]

I tried a bunch of other things including the "Editable installation". No success, sadly.

I also tried starting from scatch, removing - pyqt from environment.yml, and letting pip install stytra do it (as it's so keen on installing PyQt even if it's already there!). In that case, python -m stytra.examples.looming_exp gives a different error, maybe useful for you to diagnose?

File "/Users/francoiskroll/miniconda3/envs/stytra/lib/python3.12/site-packages/stytra/gui/fishplots.py", line 16, in class StreamingPositionPlot(pg.GraphicsWindow): ^^^^^^^^^^^^^^^^^ AttributeError: module 'pyqtgraph' has no attribute 'GraphicsWindow'. Did you mean: 'GraphicsView'?

So it's still PyQt being a pain, but at least stytra found it, I guess.

What am I missing?

francoiskroll commented 3 months ago

Ah! The following seems to start the GUI:

– remove "- pyqt" from environment.yml. – conda env create -f ~/.../environment.yml – conda activate stytra – git clone https://github.com/portugueslab/stytra.git ~/.../stytra – pip install -e ~/.../stytra

EDIT: But now I'm facing an issue with offline tracking... All goes well, then "Track video" crashes to:

File "/Users/francoiskroll/miniconda3/envs/stytra/lib/python3.12/site-packages/imageio_ffmpeg/_io.py", line 187, in count_frames_and_secs raise RuntimeError("Could not get number of frames") # pragma: no cover ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ RuntimeError: Could not get number of frames

I get this error with a video which was analysed on another machine where stytra is installed. So my installation must be to blame?

EDIT2: Yes, my installation was to blame. I found that downgrading ffmpeg from 6.1 to 6.0 solved the issue, which itself was not straightforward on my machine. In summary: – Removing old ffmpeg (not sure if necessary): conda remove ffmpeg. – The 'strict' channel_priority setting was blocking me from installing an old ffmpeg, I had to conda config --set channel_priority flexible. – conda install conda-forge::ffmpeg=6.0 – Looks like conda remove inadvertently removed PyAV, so conda install av -c conda-forge

And it works! For now at least.

nvbln commented 3 months ago

Great to hear it worked out in the end! AttributeError: module 'pyqtgraph' has no attribute 'GraphicsWindow'. Did you mean: 'GraphicsView'? Has been fixed already (see #87), but has not been released on pip yet.