Failed to import any qt binding - Spyder on Windows 10 - python

I'm trying to animate a trajectory of an object in 2D using python.
The problem is, when i try to do so I get this famous error
Traceback (most recent call last):
File "C:\Users\Pierre\OneDrive\Documents\Etudes\Master\M2\Stage\tests\sympy and gekko.py", line 13, in <module>
import matplotlib.pyplot as plt
File "C:\Python39\lib\site-packages\matplotlib\pyplot.py", line 2336, in <module>
switch_backend(rcParams["backend"])
File "C:\Python39\lib\site-packages\matplotlib\pyplot.py", line 276, in switch_backend
class backend_mod(matplotlib.backend_bases._Backend):
File "C:\Python39\lib\site-packages\matplotlib\pyplot.py", line 277, in backend_mod
locals().update(vars(importlib.import_module(backend_name)))
File "C:\Python39\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Python39\lib\site-packages\matplotlib\backends\backend_qt5agg.py", line 11, in <module>
from .backend_qt5 import (
File "C:\Python39\lib\site-packages\matplotlib\backends\backend_qt5.py", line 16, in <module>
import matplotlib.backends.qt_editor.figureoptions as figureoptions
File "C:\Python39\lib\site-packages\matplotlib\backends\qt_editor\figureoptions.py", line 11, in <module>
from matplotlib.backends.qt_compat import QtGui
File "C:\Python39\lib\site-packages\matplotlib\backends\qt_compat.py", line 177, in <module>
raise ImportError("Failed to import any qt binding")
ImportError: Failed to import any qt binding
I tried every solution I found (installing PyQt5 and importing it, reinstalling matplotlib, updating pip) and nothing works. I still get the same error every time.
I'm on windows 10 and I installed python (3.9.2) using chocolatey. I'm coding with spyder 4.2.2
I've seen someone speaking about how updating his GPU driver helped but mine is up to date and still nothing (Radeon RX580).
Does anybody have a clue on what could be the issue ?

Installing Pyside2 did the trick. No need to for the import PyQt5 if you have the option picked in the preferences of Spyder

Related

jupyter notebook python compatibility

I am totally new to Python/Jupyter notebook.
Using Windows 11. I installed latest version python Python 3.11.1. Also latest Anaconda - conda 22.9.0.
My jupyter notebook (installed by anaconda) does not start from command line:
jupyter notebook
Traceback (most recent call last):
File "C:\apps\anaconda\Scripts\jupyter-notebook-script.py", line 6, in from notebook.notebookapp import main
File "C:\apps\anaconda\lib\site-packages\notebook\notebookapp.py", line 77, in from .services.kernels.kernelmanager import MappingKernelManager, AsyncMappingKernelManager
File "C:\apps\anaconda\lib\site-packages\notebook\services\kernels\kernelmanager.py", line 18, in
from jupyter_client.session import Session
File "C:\apps\anaconda\lib\site-packages\jupyter_client_init_.py", line 8, in from .asynchronous import AsyncKernelClient # noqa
File "C:\apps\anaconda\lib\site-packages\jupyter_client\asynchronous_init_.py", line 1, in
from .client import AsyncKernelClient # noqa
File "C:\apps\anaconda\lib\site-packages\jupyter_client\asynchronous\client.py", line 6, in
from jupyter_client.channels import HBChannel
File "C:\apps\anaconda\lib\site-packages\jupyter_client\channels.py", line 12, in import zmq.asyncio
File "C:\apps\anaconda\lib\site-packages\zmq_init_.py", line 103, in from zmq import backend
File "C:\apps\anaconda\lib\site-packages\zmq\backend_init_.py", line 31, in raise original_error from None
File "C:\apps\anaconda\lib\site-packages\zmq\backend_init_.py", line 26, in ns = select_backend(first)
File "C:\apps\anaconda\lib\site-packages\zmq\backend\select.py", line 31, in select_backend mod = import_module(name)
File "C:\apps\anaconda\lib\importlib_init.py", line 127, in import_module return _bootstrap.gcd_import(name[level:], package, level)
File "C:\apps\anaconda\lib\site-packages\zmq\backend\cython_init.py", line 6, in
from . import (ImportError: DLL load failed while importing _device: The specified module could not be found.
Conda documentation states "Anaconda supports Python 3.7, 3.8, 3.9 and 3.10. The current default is Python 3.9."
Should I just downgrade my python to 3.9 or 3.10 (I dont care) ?? Any other work arounds?
Updates
Could open the jupyter notebook from the conda prompt. Not stated using it yet. So lets see. If python compatibility issues need to be resolved - need to figure it out.
But, cant start the anaconda-navigator. When I try start from windows start menu - does nothing. From Conda prompt: I get the flwg error on the prompt: >anaconda-navigator Traceback (most recent call last): File "C:\apps\anaconda\Scripts\anaconda-navigator-script.py", line 6, in <module> from anaconda_navigator.app.main import main File "C:\apps\anaconda\lib\site-packages\anaconda_navigator\app\main.py", line 19, in <module> from anaconda_navigator.app.start import start_app File "C:\apps\anaconda\lib\site-packages\anaconda_navigator\app\start.py", line 15, in <module> from qtpy.QtCore import QCoreApplication, QEvent, QObject, Qt # pylint: disable=no-name-in-module File "C:\apps\anaconda\lib\site-packages\qtpy\QtCore.py", line 15, in <module> from PyQt5.QtCore import * ImportError: DLL load failed while importing QtCore: The specified procedure could not be found.

ImportError: DLL load failed: The file cannot be accessed by the system

Traceback (most recent call last):
File "<ipython-input-9-a40793f9ded7>", line 7, in <module>
from sklearn.model_selection import train_test_split
File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\__init__.py", line 76, in <module>
from .base import clone
File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\base.py", line 16, in <module>
from .utils import _IS_32BIT
File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\utils\__init__.py", line 20, in <module>
from .validation import (as_float_array,
File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\utils\validation.py", line 21, in <module>
from .fixes import _object_dtype_isnan
File "C:\ProgramData\Anaconda3\lib\site-packages\sklearn\utils\fixes.py", line 18, in <module>
from scipy.sparse.linalg import lsqr as sparse_lsqr # noqa
File "C:\ProgramData\Anaconda3\lib\site-packages\scipy\sparse\linalg\__init__.py", line 113, in <module>
from .isolve import *
File "C:\ProgramData\Anaconda3\lib\site-packages\scipy\sparse\linalg\isolve\__init__.py", line 6, in <module>
from .iterative import *
File "C:\ProgramData\Anaconda3\lib\site-packages\scipy\sparse\linalg\isolve\iterative.py", line 10, in <module>
from . import _iterative
ImportError: DLL load failed: The file cannot be accessed by the system.
Got this error while trying to run some already used python scripts on pycharm. Has anybody had this error before and has he solved it? It started after I installed a package in python but never used it. The problem is located when I try to import train_test_split on scikit-learn and tensorflow, the sklearn package and seaborn. The other parts of the code seem unaffected.
I have already reinstalled anaconda and python as well as changing the python files. Any help would be greatly appreciated.
After reinstalling the python as well as updating all the packages (conda update --all) and changing the PATH file, it seems that the issue is solved in all of my IDE's except PyCharm. It seems that all that remains is an interpreter issue. I will post updates if something else comes into my attention.

Launch of orange3

I tried to launch of Orange 3 on Anaconda. But launch have produced errors below.
Traceback (most recent call last):
File "C:\Users\tomo\Anaconda2\envs\orange3\Scripts\orange-canvas-script.py", line 6, in
from Orange.canvas.__main__ import main
File "C:\Users\tomo\Anaconda2\envs\orange3\lib\site-packages\Orange\canvas\__main__.py", line 30, in
from Orange.canvas.application.canvasmain import CanvasMainWindow
File "C:\Users\tomo\Anaconda2\envs\orange3\lib\site-packages\Orange\canvas\application\canvasmain.py", line 61, in
from .canvastooldock import CanvasToolDock, QuickCategoryToolbar, \
File "C:\Users\tomo\Anaconda2\envs\orange3\lib\site-packages\Orange\canvas\application\canvastooldock.py", line 25, in
from ..document.quickmenu import MenuPage
File "C:\Users\tomo\Anaconda2\envs\orange3\lib\site-packages\Orange\canvas\document\__init__.py", line 17, in
from .schemeedit import SchemeEditWidget
File "C:\Users\tomo\Anaconda2\envs\orange3\lib\site-packages\Orange\canvas\document\schemeedit.py", line 37, in
from .suggestions import Suggestions
File "C:\Users\tomo\Anaconda2\envs\orange3\lib\site-packages\Orange\canvas\document\suggestions.py", line 7, in
from .interactions import NewLinkAction
File "C:\Users\tomo\Anaconda2\envs\orange3\lib\site-packages\Orange\canvas\document\interactions.py", line 28, in
from ..canvas import items
File "C:\Users\tomo\Anaconda2\envs\orange3\lib\site-packages\Orange\canvas\canvas\items\__init__.py", line 9, in
from .annotationitem import TextAnnotation, ArrowAnnotation
File "C:\Users\tomo\Anaconda2\envs\orange3\lib\site-packages\Orange\canvas\canvas\items\annotationitem.py", line 7, in
import CommonMark
ModuleNotFoundError: No module named 'CommonMark'
Acutually I found these error on this web and tried to install the r-commonmark 1.4 but it does not work well now.
Please tell me how to deal with it.
CommonMark is a package that Orange used. It was renamed in the latest release what causes that imports do not work. The issue should be solved by installing newer Orange3 version3.16.0

ImportError: No module named FileDialog - after PyInstaller

I have written a program that I have tried to turn into an executable using PyInstaller. Pyinstaller appears to have finished without any errors and I end up with an application in /dist/my_program. However, when I try to run that application a console window flashes up for a second with a traceback:
Edit: I have copied the traceback out. There may be a mistake as I had to type it up from a screenshot because it only flashes up.
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "C:\Users\user\desktop\PyInstaller-2.1\PyInstaller\loader\pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "C:\Users\user\desktop\PyInstaller-2.1\my_program\build\my_program\out00-PYZ.pyz\matplotlib.pyplot", line 108, in <module>
File "C:\Users\user\desktop\PyInstaller-2.1\my_program\build\my_program\out00-PYZ.pyz\matplotlib.backends", line 32, in pylab_setup
File "C:\Users\user\desktop\PyInstaller-2.1\PyInstaller\loader\pyi_importers.py", line 270, in load_module
exec(bytecode, module.__dict__)
File "C:\Users\user\desktop\PyInstaller-2.1\my_program\build\my_program\out00-PYZ.pyz\matplotlib.backends.backend_tkagg", line 7, in <module>
File "C:\Users\user\desktop\PyInstaller-2.1\my_program\build\my_program\out00-PYZ.pyz\six", line 194, in load_module
File "C:\Users\user\desktop\PyInstaller-2.1\my_program\build\my_program\out00-PYZ.pyz\six", line 108, in _resolve
File "C:\Users\user\desktop\PyInstaller-2.1\my_program\build\my_program\out00-PYZ.pyz\six", line 779, in _import_module
ImportError: No module named FileDialog
Below are the imports that I have in my code:
import Tkinter
from tkFileDialog import askopenfilename
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.mlab as mlab
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
import subprocess
from PIL import Image, ImageTk
import os
Does anyone know whats causing this/what the fix is? I presume the error is the importation of tkFileDialog?
Edit2: the program runs fine when I run it in my interpreter (Spyder) but when I packaged it using PyInstaller the resulting application gives this error.
According to this question adding import FileDialog solves the problem. Matplotlib seems to need this.
However, I've used Pyinstaller on a script of mine also importing matplotlib and it gives no such error. So I don't know what exacly is the problem here.

Problem importing pylab in Ubuntu 8.1

I have installed numpy1.3,scipy 0.7.1,matplotlib 0.99.1.1 and python 2.5
when I import pylab I get the following error. Someone please help.
/var/lib/python-support/python2.5/gtk-2.0/gtk/__init__.py:72: GtkWarning: could not open display
warnings.warn(str(e), _gtk.Warning)
/usr/lib/python2.5/site-packages/matplotlib/backends/backend_gtk.py:44: GtkWarning: gdk_cursor_new_for_display: assertion `GDK_IS_DISPLAY (display)' failed
cursors.MOVE : gdk.Cursor(gdk.FLEUR),
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.5/site-packages/pylab.py", line 1, in <module>
from matplotlib.pylab import *
File "/usr/lib/python2.5/site-packages/matplotlib/pylab.py", line 247, in <module>
from matplotlib.pyplot import *
File "/usr/lib/python2.5/site-packages/matplotlib/pyplot.py", line 78, in <module>
new_figure_manager, draw_if_interactive, show = pylab_setup()
File "/usr/lib/python2.5/site-packages/matplotlib/backends/__init__.py", line 25, in pylab_setup
globals(),locals(),[backend_name])
File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_gtkagg.py", line 10, in <module>
from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK, FigureCanvasGTK,\
File "/usr/lib/python2.5/site-packages/matplotlib/backends/backend_gtk.py", line 44, in <module>
cursors.MOVE : gdk.Cursor(gdk.FLEUR),
RuntimeError: could not create GdkCursor object
try using a different backend for plotting than Gtk.
Open the python console and type:
>>> import matplotlib
>>> matplotlib.matplotlib_fname()
This will print a file name. Edit this file and modify the section 'Backend' and change Gtk or GtkAgg with any other (see the documentation in the same file), until you get it working.
You can find more information about backends here.
As for why you get an error when you try to use that backend, it depends on how you have installed the libraries and what you have installed on your computer. I would recommend to install matplotlib with synaptic/yum and selecting all optional dependencies.

Categories

Resources