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

ImportError: Failed to import any of the following Qt binding modules: PyQt5, PySide2 #2

Open
adthoms opened this issue Oct 2, 2023 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@adthoms
Copy link

adthoms commented Oct 2, 2023

Following the current installation guide, the following errors are reproduced when running:

python3 hat_experiments.py:

Traceback (most recent call last):
  File "/home/alex/catkin_ws/src/cora-experiments/experiments/hat_experiments.py", line 2, in <module>
    from py_factor_graph.io.pyfg_text import read_from_pyfg_text
  File "/home/alex/catkin_ws/src/PyFactorGraph/py_factor_graph/io/pyfg_text.py", line 3, in <module>
    from py_factor_graph.factor_graph import FactorGraphData
  File "/home/alex/catkin_ws/src/PyFactorGraph/py_factor_graph/factor_graph.py", line 51, in <module>
    from py_factor_graph.utils.plot_utils import (
  File "/home/alex/catkin_ws/src/PyFactorGraph/py_factor_graph/utils/plot_utils.py", line 11, in <module>
    from evo.tools import file_interface, plot as evoplot
  File "/home/alex/anaconda3/envs/cora/lib/python3.10/site-packages/evo/tools/plot.py", line 33, in <module>
    mpl.use(SETTINGS.plot_backend)
  File "/home/alex/anaconda3/envs/cora/lib/python3.10/site-packages/matplotlib/__init__.py", line 1249, in use
    plt.switch_backend(name)
  File "/home/alex/anaconda3/envs/cora/lib/python3.10/site-packages/matplotlib/pyplot.py", line 342, in switch_backend
    module = importlib.import_module(cbook._backend_module_name(newbackend))
  File "/home/alex/anaconda3/envs/cora/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/alex/anaconda3/envs/cora/lib/python3.10/site-packages/matplotlib/backends/backend_qt5agg.py", line 7, in <module>
    from .backend_qtagg import (    # noqa: F401, E402 # pylint: disable=W0611
  File "/home/alex/anaconda3/envs/cora/lib/python3.10/site-packages/matplotlib/backends/backend_qtagg.py", line 9, in <module>
    from .qt_compat import QT_API, QtCore, QtGui
  File "/home/alex/anaconda3/envs/cora/lib/python3.10/site-packages/matplotlib/backends/qt_compat.py", line 133, in <module>
    raise ImportError(
ImportError: Failed to import any of the following Qt binding modules: PyQt5, PySide2

python3 tiers_experiments.py:

Traceback (most recent call last):
  File "/home/alex/catkin_ws/src/cora-experiments/experiments/tiers_experiments.py", line 1, in <module>
    from py_factor_graph.io.pyfg_text import read_from_pyfg_text
  File "/home/alex/catkin_ws/src/PyFactorGraph/py_factor_graph/io/pyfg_text.py", line 3, in <module>
    from py_factor_graph.factor_graph import FactorGraphData
  File "/home/alex/catkin_ws/src/PyFactorGraph/py_factor_graph/factor_graph.py", line 51, in <module>
    from py_factor_graph.utils.plot_utils import (
  File "/home/alex/catkin_ws/src/PyFactorGraph/py_factor_graph/utils/plot_utils.py", line 11, in <module>
    from evo.tools import file_interface, plot as evoplot
  File "/home/alex/anaconda3/envs/cora/lib/python3.10/site-packages/evo/tools/plot.py", line 33, in <module>
    mpl.use(SETTINGS.plot_backend)
  File "/home/alex/anaconda3/envs/cora/lib/python3.10/site-packages/matplotlib/__init__.py", line 1249, in use
    plt.switch_backend(name)
  File "/home/alex/anaconda3/envs/cora/lib/python3.10/site-packages/matplotlib/pyplot.py", line 342, in switch_backend
    module = importlib.import_module(cbook._backend_module_name(newbackend))
  File "/home/alex/anaconda3/envs/cora/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "/home/alex/anaconda3/envs/cora/lib/python3.10/site-packages/matplotlib/backends/backend_qt5agg.py", line 7, in <module>
    from .backend_qtagg import (    # noqa: F401, E402 # pylint: disable=W0611
  File "/home/alex/anaconda3/envs/cora/lib/python3.10/site-packages/matplotlib/backends/backend_qtagg.py", line 9, in <module>
    from .qt_compat import QT_API, QtCore, QtGui
  File "/home/alex/anaconda3/envs/cora/lib/python3.10/site-packages/matplotlib/backends/qt_compat.py", line 133, in <module>
    raise ImportError(
ImportError: Failed to import any of the following Qt binding modules: PyQt5, PySide2

single_drone_experiments.py:

[pyfg_text.py:686] py_factor_graph.utils.logging_utils INFO - Loaded factor graph in PyFG text format from /home/alex/catkin_ws/src/cora-experiments/data/single_drone/factor_graph.pyfg
Reading data from /home/alex/catkin_ws/src/cora-experiments/data/single_drone/factor_graph.pyfg
Finished loading data in 1.305308 seconds.
Manopt settings:
 Solver verbosity: 0
 Initialization strategy: random
 Setting stopping tolerance for norm of Riemannian gradient to: 0.001 [default]
 Setting stopping tolerance for relative function decrease to: 1e-05 [default]
 Setting maximum number of Hessian-vector products to evaluate in each truncated Newton iteration to: 300 [default]
 Setting minimum number of trust-region iterations to: 1 [default]
 Setting maximum number of trust-region iterations to: 100 [default]

Solving Riemannian optimization problems using Manopt's "trustregions" solver

Setting up preconditioner...
Warning: No valid initialization given. Using random point as default.
> In cora (line 52)
In cora_python_interface (line 40)
Trying to solve at rank 3
Trying to solve at rank 4
Trying to solve at rank 5
Solution certified with certEpsilon = 4.010953e-06 
The staircase algorithm has found an optimal solution with dimension 5 and cost 4.010953.
Singular values of lifted solution are: [51.8178086219621;47.0618163433195;41.8810223594389;19.0275923098514;0.175639129004057] 
Refined cost is 4.095614
Warning: Gap: 8.466121e-02 Rel Gap: 2.110751e+00
> In cora (line 119)
In cora_python_interface (line 40)
Warning: Gap between final solution and optimal solution is 0.084661
> In cora (line 125)
In cora_python_interface (line 40)
Warning: Relative suboptimality is 2.110751%
> In cora (line 126)
In cora_python_interface (line 40)
Results saved to /home/alex/catkin_ws/src/cora-experiments/data/single_drone/factor_graph_results.mat
CORA iterates info saved to /home/alex/catkin_ws/src/cora-experiments/data/single_drone/factor_graph_cora_iterates_info.mat
Warning: Function does not currently correctly handle priors!!
> In write_result_to_tum (line 14)
In cora_python_interface (line 54)
Warning: Assuming no priors - get_robot t_idxs
> In get_robot_t_idxs (line 4)
In write_result_to_tum (line 37)
In cora_python_interface (line 54)
Warning: Assuming no priors - get_robot_R_idxs
> In get_robot_R_idxs (line 4)
In write_result_to_tum (line 38)
In cora_python_interface (line 54)
[evaluate_utils.py:349] utils.logging_utils INFO - Found PyFG file: /home/alex/catkin_ws/src/cora-experiments/data/single_drone/factor_graph.pyfg
[pyfg_text.py:686] py_factor_graph.utils.logging_utils INFO - Loaded factor graph in PyFG text format from /home/alex/catkin_ws/src/cora-experiments/data/single_drone/factor_graph.pyfg
Traceback (most recent call last):
  File "/home/alex/catkin_ws/src/cora-experiments/experiments/single_drone_experiments.py", line 34, in <module>
    run_experiments(pyfg, experiments, exp_config)
  File "/home/alex/catkin_ws/src/cora-experiments/experiments/utils/run_experiments.py", line 166, in run_experiments
    _perform_evaluation(
  File "/home/alex/catkin_ws/src/cora-experiments/experiments/utils/run_experiments.py", line 63, in _perform_evaluation
    make_evo_traj_plots(
  File "/home/alex/catkin_ws/src/cora-experiments/experiments/utils/evaluate_utils.py", line 546, in make_evo_traj_plots
    fig = plt.figure(figsize=(20, 10))
  File "/home/alex/anaconda3/envs/cora/lib/python3.10/site-packages/matplotlib/pyplot.py", line 934, in figure
    manager = new_figure_manager(
  File "/home/alex/anaconda3/envs/cora/lib/python3.10/site-packages/matplotlib/pyplot.py", line 464, in new_figure_manager
    _warn_if_gui_out_of_main_thread()
  File "/home/alex/anaconda3/envs/cora/lib/python3.10/site-packages/matplotlib/pyplot.py", line 441, in _warn_if_gui_out_of_main_thread
    canvas_class = cast(type[FigureCanvasBase], _get_backend_mod().FigureCanvas)
  File "/home/alex/anaconda3/envs/cora/lib/python3.10/site-packages/matplotlib/pyplot.py", line 280, in _get_backend_mod
    switch_backend(rcParams._get("backend"))  # type: ignore[attr-defined]
  File "/home/alex/anaconda3/envs/cora/lib/python3.10/site-packages/matplotlib/pyplot.py", line 342, in switch_backend
    module = importlib.import_module(cbook._backend_module_name(newbackend))
  File "/home/alex/anaconda3/envs/cora/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/home/alex/anaconda3/envs/cora/lib/python3.10/site-packages/matplotlib/backends/backend_qt5agg.py", line 7, in <module>
    from .backend_qtagg import (    # noqa: F401, E402 # pylint: disable=W0611
  File "/home/alex/anaconda3/envs/cora/lib/python3.10/site-packages/matplotlib/backends/backend_qtagg.py", line 9, in <module>
    from .qt_compat import QT_API, QtCore, QtGui
  File "/home/alex/anaconda3/envs/cora/lib/python3.10/site-packages/matplotlib/backends/qt_compat.py", line 133, in <module>
    raise ImportError(
ImportError: Failed to import any of the following Qt binding modules: PyQt5, PySide2

PyQt5 is installed here, and solutions to similar issues (see 1, 2) have not provided a fix. In testing tiers_experiments.py and hat_experiments.py, it appears that forcing matplotlib's backend to 'QtAgg' provides a fix. This fix is not reproduced in the single_drone_experiments.py.

@adthoms adthoms added the bug Something isn't working label Oct 2, 2023
@adthoms adthoms self-assigned this Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant