0

This may be a simple question for many of you but I need a bit of help. I have been having problems when running matplotlib from command line in windows 10. I get this error: This application failed to start because it could not find or load the Qt platform plugin "windows" in "". I recently updated and perhaps installed something which changed and it no longer works when it did previously. Matplotlib also works fine if I run from spyder, but what I want to be doing is actually launching a gui made with PyQt5 which used to work fine but gives the above error as I am calling matplotlib, if I run a script just with matplotlib I get the same error but I also get the same error when calling a simple pyqt example from https://github.com/baoboa/pyqt5/tree/master/examples which used to work just fine also. When I try and run the qt gui from spyder nothing happens and the kernel is restarted. I can run just the gui design from spyder and it is displayed correctly but I get the same error when running from windows command processor as above.

I have found from this previous post Error "could not find or load the Qt platform plugin windows" while using matplotlib in pycharm that it is suggested to set QT_PLUGIN_PATH to C:\ProgramData\Anaconda3\Library\plugins However I don't have QT_PLUGIN_PATH as an option. If I create new variable and add the path to the plugins it doesn't help. In the plugins/platforms there is qwindows, qoffscreen and qminimal.dll I am confused as to why when running from the command line by python main.py I get the above error and also when running from spyder the gui doesn't appear. I am generally just lost here...

Thanks for any help Sorry, I am also running python 3.6. I recently updated for the new spyder release. My matplotlib is 2.1.0 and PyQt5 version 5.6.0

Robin White
  • 159
  • 2
  • 11
  • The error means that Qt failed to load `qwindows.dll`. This can be because Qt does not search in the right path, in this case as you figured out you can use `QT_PLUGIN_PATH` environment variable to fix it. Or it might be because Qt cannot load the plugin because it is incompatible: not the same Qt version or not the same compiler. You might be able to check for this by using some tools like dependency walker. – Benjamin T Nov 15 '17 at 12:08
  • Thanks @BenjaminT I am still a little confused about the QT_PLUGIN_PATH, do I just add it as a new variable in the system or user environment? I did just have a work around with a new conda environment which seems to work just fine. It would be great if I could still fix it just for my own sanity though. If it works within a new environment does that add any helpful information? – Robin White Nov 16 '17 at 16:34
  • You just do `set QT_PLUGIN_PATH="C:\..."` on Windows command line (`export QT_PLUGIN_PATH="..."` in bash). What would be helpful is the difference between the environment that works and the one that doesn't. – Benjamin T Nov 16 '17 at 17:00

1 Answers1

1

check qt.conf in the root folder of your environment [C:\ProgramData\Anaconda3\qt.conf]. The paths in there are absolute. Make sure they point to the insides of the environment. I moved my environment folder to a different location and then spent two days trying to resolve this error.

cudima
  • 414
  • 4
  • 11