uvemas / ViTables

ViTables, a GUI for PyTables
GNU General Public License v3.0
153 stars 55 forks source link

vitables fails to launch with "cannot import name 'loadUiType' from 'qtpy.uic'" #97

Closed AgilentGCMS closed 4 years ago

AgilentGCMS commented 4 years ago

I installed qtpy and PyQt5 through my system's package manager, and vitables with pip3 install vitables, but when I try to start it,

$ vitables
Traceback (most recent call last):
  File "/Users/sbasu1/packages/macports/bin/vitables", line 5, in <module>
    from vitables.start import gui
  File "/Users/sbasu1/packages/macports/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/vitables/start.py", line 31, in <module>
    from vitables.vtapp import VTApp
  File "/Users/sbasu1/packages/macports/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/vitables/vtapp.py", line 36, in <module>
    import vitables.utils
  File "/Users/sbasu1/packages/macports/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/vitables/utils.py", line 41, in <module>
    import vitables.vtwidgets.renamedlg as renamedlg
  File "/Users/sbasu1/packages/macports/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/vitables/vtwidgets/renamedlg.py", line 52, in <module>
    from qtpy.uic import loadUiType
ImportError: cannot import name 'loadUiType' from 'qtpy.uic' (/Users/sbasu1/packages/macports/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/qtpy/uic.py)

I know that both qtpy and PyQt5 are installed for the python installation vitables is running in:

In [1]: import qtpy

In [2]: import PyQt5

In [3]: qtpy.__file__
Out[3]: '/Users/sbasu1/packages/macports/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/qtpy/__init__.py'

In [4]: PyQt5.__file__
Out[4]: '/Users/sbasu1/packages/macports/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/PyQt5-5.14.1-py3.8-macosx-10.14-x86_64.egg/PyQt5/__init__.py'

And yet vitables won't start. To see what was going on, I tried putting a print statement in /Users/sbasu1/packages/macports/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/qtpy/uic.py, like so

import os

from . import PYSIDE, PYSIDE2, PYQT4, PYQT5
from .QtWidgets import QComboBox
print(PYQT4, PYQT5)

and sure enough, both of them were False. So I'm not sure why vitables won't work. Any help would be appreciated.

AgilentGCMS commented 4 years ago

My PyQt5, qtpy, pyside and sip were installed with the system package manager. When I uninstalled those and allowed pip3 to pull in vitables dependencies, this is what it did:

$ pip3 install vitables
Collecting vitables
  Downloading ViTables-3.0.2-py3-none-any.whl (1.0 MB)
     |████████████████████████████████| 1.0 MB 4.1 MB/s
Requirement already satisfied: numexpr>=2.0 in /Users/sbasu1/packages/macports/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from vitables) (2.7.1)
Requirement already satisfied: tables>=3.0 in /Users/sbasu1/packages/macports/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tables-3.6.2.dev0-py3.8-macosx-10.14-x86_64.egg (from vitables) (3.6.2.dev0)
Requirement already satisfied: numpy>=1.4.1 in /Users/sbasu1/packages/macports/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from vitables) (1.18.1)
Requirement already satisfied: qtpy>=1.2.1 in /Users/sbasu1/packages/macports/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from vitables) (1.9.0)
Requirement already satisfied: PyQt5>=5.5.1 in /Users/sbasu1/packages/macports/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/PyQt5-5.14.1-py3.8-macosx-10.14-x86_64.egg (from vitables) (5.14.1)
Requirement already satisfied: PyQt5-sip<13,>=12.7 in /Users/sbasu1/packages/macports/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from PyQt5>=5.5.1->vitables) (12.7.0)
Installing collected packages: vitables
Successfully installed vitables-3.0.2

However, vitables still does not start

$ vitables
Traceback (most recent call last):
  File "/Users/sbasu1/packages/macports/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/qtpy/__init__.py", line 204, in <module>
    from PySide import __version__ as PYSIDE_VERSION  # analysis:ignore
ModuleNotFoundError: No module named 'PySide'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/sbasu1/packages/macports/bin/vitables", line 5, in <module>
    from vitables.start import gui
  File "/Users/sbasu1/packages/macports/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/vitables/start.py", line 28, in <module>
    import qtpy.QtCore as qtcore
  File "/Users/sbasu1/packages/macports/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/qtpy/__init__.py", line 210, in <module>
    raise PythonQtError('No Qt bindings could be found')
qtpy.PythonQtError: No Qt bindings could be found

So it seems like (1) vitables absolutely needs pyside, and (2) despite pip3 saying that PyQt5 got installed, vitables can't find it.

uvemas commented 4 years ago

Well, it seems that something is messy in your system. You say that have uninstalled PyQt5, qtpy, pyside and sip and then installed vitables via pip3. In that case the expected result is a new installation of PyQt5 (and sip) and qtpy because they are vitables dependencies. However the output of your pip3 install vitables command says that PyQt5 (and sip) and qtpy were already satisfied dependencies and the only installed package is vitables.

I've done the same thing (in a virtual environment, not with the system Python) and got the following result:

$ pip install ViTables                                                                                                                                 
Collecting ViTables                                                                                                                                    
  Using cached ViTables-3.0.2-py3-none-any.whl (1.0 MB)                                                                                                
Collecting PyQt5>=5.5.1                                                                                                                                
  Using cached PyQt5-5.14.1-5.14.0-cp35.cp36.cp37.cp38-none-win_amd64.whl (52.9 MB)                                                                    
Collecting qtpy>=1.2.1                                                                                                                                 
  Using cached QtPy-1.9.0-py2.py3-none-any.whl (54 kB)                                                                                                 
Requirement already satisfied: numpy>=1.4.1 in c:\users\uvema\.virtualenvs\vitablesve2\lib\site-packages (from ViTables) (1.17.4+mkl)                  
Requirement already satisfied: tables>=3.0 in c:\users\uvema\.virtualenvs\vitablesve2\lib\site-packages (from ViTables) (3.6.1)                        
Requirement already satisfied: numexpr>=2.0 in c:\users\uvema\.virtualenvs\vitablesve2\lib\site-packages (from ViTables) (2.7.0)                       
Requirement already satisfied: PyQt5-sip<13,>=12.7 in c:\users\uvema\.virtualenvs\vitablesve2\lib\site-packages (from PyQt5>=5.5.1->ViTables) (12.7.0) 
Installing collected packages: PyQt5, qtpy, ViTables                                                                                                   
Successfully installed PyQt5-5.14.1 ViTables-3.0.2 qtpy-1.9.0                                                                                          

Then I've run the vitables command and ViTables runs just fine (pyside is not installed in the virtual environment).

The second thing that confuses me is: if PyQt5 is installed (because apparently it was not uninstalled) and Pyside is probably installed too (because its uninstallation also failed) then why qtpy cannot find any Qt bindings?

The only thing that comes to my mind is that for some reason pyside, pyqt5 and qtpy have not been properly installed/uninstalled/installed again and they are somehow broken.

My advice is the same that gave you in #96: install vitables in a new, fresh virtual environment, you don't need pyside at all.

Unfortunately I have not a MacOs X for testing vitables so I think I cannot give you more help. Anyway, if your problem persists just let us know. Maybe some other user will be able to help you.

AgilentGCMS commented 4 years ago

So I did a very careful cleanup of my system to get rid of all PyQt5, PyQt5-sip and qtpy, and did and pip3 install, which gave

$ pip3 install vitables
Collecting vitables
  Using cached ViTables-3.0.2-py3-none-any.whl (1.0 MB)
Requirement already satisfied: numpy>=1.4.1 in ./packages/macports/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from vitables) (1.18.1)
Requirement already satisfied: numexpr>=2.0 in ./packages/macports/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages (from vitables) (2.7.1)
Collecting PyQt5>=5.5.1
  Downloading PyQt5-5.14.1-5.14.0-cp35.cp36.cp37.cp38-abi3-macosx_10_6_intel.whl (43.0 MB)
     |████████████████████████████████| 43.0 MB 15.7 MB/s
Collecting qtpy>=1.2.1
  Downloading QtPy-1.9.0-py2.py3-none-any.whl (54 kB)
     |████████████████████████████████| 54 kB 8.2 MB/s
Requirement already satisfied: tables>=3.0 in ./packages/macports/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/tables-3.6.2.dev0-py3.8-macosx-10.14-x86_64.egg (from vitables) (3.6.2.dev0)
Collecting PyQt5-sip<13,>=12.7
  Downloading PyQt5_sip-12.7.0-cp38-cp38-macosx_10_9_x86_64.whl (63 kB)
     |████████████████████████████████| 63 kB 7.0 MB/s
Installing collected packages: PyQt5-sip, PyQt5, qtpy, vitables
Successfully installed PyQt5-5.14.1 PyQt5-sip-12.7.0 qtpy-1.9.0 vitables-3.0.2

Running vitables after that worked, so all is well!

I was trying to have one maintaining system for python packages, between macports and pip3, which is why I tried installing the PyQt5 stuff through macports initially. I guess it was not to be...