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

Problem with GUI import #45

Open
PaolaGith opened this issue May 10, 2023 · 14 comments
Open

Problem with GUI import #45

PaolaGith opened this issue May 10, 2023 · 14 comments

Comments

@PaolaGith
Copy link

Hello,
I installed spikeinterface GUI from

git clone https://github.com/SpikeInterface/spikeinterface-gui.git
cd spikeinterface-gui
pip install .

The GUI was installed as "spikeinterface-gui 0.6.0 "

However, when I import it I get an error:

import matplotlib.pyplot as plt
import numpy as np
from pathlib import Path
import spikeinterface-gui as sigui
%matplotlib inline
%matplotlib notebook
Cell In[36], line 6
    import spikeinterface-gui as sigui
                         ^
SyntaxError: invalid syntax

So I tried to replace the - with the underscore (_), but I get a different error:

import matplotlib.pyplot as plt
import numpy as np
from pathlib import Path
import spikeinterface_gui as sigui
%matplotlib inline
%matplotlib notebook
ImportError                               Traceback (most recent call last)
Cell In[37], line 6
      3 from pathlib import Path
      5 #import ephyviewer
----> 6 import spikeinterface_gui as sigui
      8 # %matplotlib widget
      9 get_ipython().run_line_magic('matplotlib', 'inline')

File ~/anaconda3/envs/s_i/lib/python3.10/site-packages/spikeinterface_gui/__init__.py:7
      1 """
      2 GUI without copy on top of spikeinterface objects
      3 """
      5 from .version import version as __version__
----> 7 from .myqt import QT, mkQApp
      8 from .mainwindow import MainWindow
      9 from .controller import SpikeinterfaceController

ImportError: cannot import name 'mkQApp' from 'spikeinterface_gui.myqt' (/home/paola322/anaconda3/envs/s_i/lib/python3.10/site-packages/spikeinterface_gui/myqt.py)

Any idea of why this happens and how can I fix it?

Thank you!

@samuelgarcia
Copy link
Member

Hi Paola.
Thanks you for report.
import spikeinterface_gui as sigui is the correct way.

For the second error: I think you need to install PyQt5 or PySide6
I you are on anaconda you should do conda install pyqt=5

@PaolaGith
Copy link
Author

Hi Samuel,

thanks for your answer.
I ran conda install pyqt=5 and installed the libraries, but I get the same error.

ImportError: cannot import name 'mkQApp' from 'spikeinterface_gui.myqt' (/home/paola322/anaconda3/envs/s_i/lib/python3.10/site-packages/spikeinterface_gui/myqt.py)

@samuelgarcia
Copy link
Member

Are you able to run
import PyQt5 in your env ?

@PaolaGith
Copy link
Author

PaolaGith commented May 10, 2023

It gives me the same error...

Actually all these libraries are already installed in my environment.

pyqt                      5.15.7          py310h6a678d5_1  
pyqt5                     5.15.9                   pypi_0    pypi
pyqt5-qt5                 5.15.2                   pypi_0    pypi
pyqt5-sip                 12.12.1                  pypi_0    pypi
pyqt6                     6.4.2                    pypi_0    pypi
pyqt6-qt6                 6.4.3                    pypi_0    pypi
pyqt6-sip                 13.4.1                   pypi_0    pypi
pyqtgraph                 0.13.2                   pypi_0    pypi
pyrsistent                0.19.3                   pypi_0    pypi
pyside2                   5.15.2.1                 pypi_0    pypi
pyside6                   6.4.3                    pypi_0    pypi
pyside6-addons            6.4.3                    pypi_0    pypi
pyside6-essentials        6.4.3                    pypi_0    pypi

However they are not recognized, that's why I can't use ephyviewer. That's why I am trying to use the GUI...

@samuelgarcia
Copy link
Member

OK I guess th problem.
You have all of then in the same env! You should choose only one of then otherwise it is buggy.
I would choose pyqt5. Try to remove pyside2 and pyside6 and pyqt6

@PaolaGith
Copy link
Author

PaolaGith commented May 10, 2023

Dear Samuel,
I have removed those packages.
Now the list of the libraries is:

pyqt                      5.15.7          py310h6a678d5_1  
pyqt5                     5.15.9                   pypi_0    pypi
pyqt5-qt5                 5.15.2                   pypi_0    pypi
pyqt5-sip                 12.12.1                  pypi_0    pypi
pyqtgraph                 0.13.2                   pypi_0    pypi

Nevertheless I get the same error when importing:

ImportError                               Traceback (most recent call last)
Cell In[2], line 6
      3 from pathlib import Path
      5 #import ephyviewer
----> 6 import spikeinterface_gui as sigui
      7 #import PyQt5
      8 
      9 # %matplotlib widget
     10 get_ipython().run_line_magic('matplotlib', 'inline')

File ~/anaconda3/envs/s_i/lib/python3.10/site-packages/spikeinterface_gui/__init__.py:7
      1 """
      2 GUI without copy on top of spikeinterface objects
      3 """
      5 from .version import version as __version__
----> 7 from .myqt import QT, mkQApp
      8 from .mainwindow import MainWindow
      9 from .controller import SpikeinterfaceController

mportError: cannot import name 'mkQApp' from 'spikeinterface_gui.myqt' (/home/paola322/anaconda3/envs/s_i/lib/python3.10/site-packages/spikeinterface_gui/myqt.py)

@samuelgarcia
Copy link
Member

You are really unlucky (and also pyqt5 is a pain for installtion in conda)

What you need is this working:

import PyQt5
from PyQt5 import QtCore, QtGui, QtWidgets

You have both pyqt5 and pyqt in your env.
This look like a conflict
My guess is that you have installed both using conda install pyqt=5 and pip install PyQt5.
You should choose only one for instance conda for both pyqtgraph and pyqt.
conda install pyqt=5
conda install pyqtgraph

Here you should have working envs for installtion spikeinetrface + spiekinetrface-gui
https://github.com/SpikeInterface/spikeinterface/tree/main/installation_tips
Maybe download the yml and modify then to your needs.

@PaolaGith
Copy link
Author

So you suggest me to re-install spikeinterface?
I already have my spikeinterface environment (s_i) and I am afraid to re-install it then I will face again all the problems I faced already to be able to use it .I am not an expert on python and I wasted weeks try to troubleshoot issues...
What if I uninstall

pyqt                      5.15.7          py310h6a678d5_1  
pyqt5                     5.15.9                   pypi_0    pypi
pyqt5-qt5                 5.15.2                   pypi_0    pypi
pyqt5-sip                 12.12.1                  pypi_0    pypi
pyqtgraph                 0.13.2                   pypi_0    pypi

and I install only these two as you suggested?

conda install pyqt=5
conda install pyqtgraph

Currently, if I try to import these:

import PyQt5
from PyQt5 import QtCore, QtGui, QtWidgets

I get:

ImportError                               Traceback (most recent call last)
Cell In[3], line 8
      5 #import ephyviewer
      7 import PyQt5
----> 8 from PyQt5 import QtCore, QtGui, QtWidgets
      9 import spikeinterface_gui as sigui
     10 # %matplotlib widget

ImportError: libGL.so.1: cannot open shared object file: No such file or directory

When I installed spikeinterface I cloned the link.

@samuelgarcia
Copy link
Member

Maybe

pip uninstall pyqt5
pip uninstall pyqt5-qt5
pip uninstall pyqt5-sip
pip uninstall pyqtgraph
conda install pyqt=5
conda install pyqtgraph

@PaolaGith
Copy link
Author

PaolaGith commented May 11, 2023

Hi Samuel,
I deleted and reinstalled the libraries. Currently my list is:

pyparsing                 3.0.9           py310h06a4308_0  
pyqt                      5.15.7          py310h6a678d5_1  
pyqt5-sip                 12.11.0                  pypi_0    pypi
pyqtgraph     

Nevertheless I get the same error if I try to import spikeinterface_gui:

ImportError: cannot import name 'mkQApp' from 'spikeinterface_gui.myqt' (/home/paola322/anaconda3/envs/s_i/lib/python3.10/site-packages/spikeinterface_gui/myqt.py)

And if I try to import:

import PyQt5
from PyQt5 import QtCore, QtGui, QtWidgets

ImportError: cannot import name 'QtCore' from 'PyQt5' (unknown location)`

I tried also to export to phy, since I really need to perform a manual curation: I can export to phy but I can't see the display...

@rohanmalige
Copy link

Hi,

I am trying to run the spike interface-gui in a docker container and then using jupyter notebook for some data analysis. I get the same error as the person above. Any recommendations or suggestions?

Thanks.

@samuelgarcia
Copy link
Member

Lauching sigui from jupyter should be avoid. (we have in docs for demonstration but should be avoid)
Qt and jupyter event loop do not play weel I think.
You should have a separated python script that run sigui or run it from a terminal.

@rohanmalige
Copy link

Hi @samuelgarcia,

Thank you for the prompt response and greatly appreciate the help! Could you please clarify on what python script should contain that can run sigui. Or how to run sigui on the terminal, to be more specific I need these to run in a docker container.

Thank you,
Rohan

@samuelgarcia
Copy link
Member

Hi.
The way of launching sigui are describe here for python script or command line

Doing GUi stuff inside a docker can be quite tricky specially from windows host because there is a need of a X server display. Even host linux can be annoying. My knowlegde on docker system will be limited to help you on this. I am sorry.

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