I am building a plugin based around PyQt5.QtChart

This line will not work as QGIS (3.8) appears to use its own python. It works fine in my python IDE. I have confirmed that QGIS is using a different version.

from PyQt5.QtChart import QChart,QChartView,QLineSeries

I tried installing PyQt5.QtChart within my plugin's local directory in a lib subdirectory but cannot get QGIS3 to load it. I've tried many combinations of import but none seem to load the QtChart.so file.

Pycharm is the IDE but I need this to work for other users

  • Depending on your IDE, you might be able to configure it ( the IDE), to use the python instance bundled with your qgis. VS Code for example lets you choose which python .exe scripts should be run against. Maybe this can help you.
    – jdoe
    Oct 9 '19 at 11:03
  • what IDE are you using ? Oct 11 '19 at 1:01
  • Pycharm is the IDE but I need this to work for other users Oct 12 '19 at 11:27

I use Mac and QGIS 3.4 and got the same error. After checking the PyQt5 folder in QGIS, I found there is no QtChart file in the folder, which is the reason why we cannot import it. And the version of PyQt5 in QGIS is 5.11.3 The folder for PyQt5 in QGIS is


I have an anaconda version of PyQt5, which can import QtChart, the version is 5.13.1.

I tried to copy the QtChart.so file from the anaconda PyQt5 folder to QGIS PyQT5 folder, but it doesn't work.

Check @Cody-chen method from the link below to see if it can solve your problem. https://github.com/ghostop14/sparrow-wifi/issues/1

I use pip to install PyQt5 for the system version of Python, which turns out it also doesn't include QtChart. python3 -m pip install PyQt5==5.13.1

After that, I use python3 -m pip install PyQtChart, then system Python can import QtChart, so I think pip install default method won't install QtChart.

Though QGIS on Mac uses the system version of Python, and it can import QtChart. But I still cannot import it in QGIS, because QGIS has its own PyQt5 folder. I haven't find a way to solve that. Sorry.

  • Thanks for the comments but I can't mark this as an answer as it does not solve my question which is getting to QtChart in QGIS Oct 12 '19 at 11:33
  • Thanks @CitizenFish, I understand that. It's also a problem for me. Hope someone can answer it.
    – Zac
    Oct 12 '19 at 11:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.