PB writing GX extensions with Python - does not import matplotlib

Hello, I have some issues trying to write GX extensions with Python.
In fact, it seems that it is not possible to import matplotlib packages, nor PyQT5 packages.
Is it a known limitation or can I try to fix it?
It seems to me that it has to do with the “backend” choice, but I’m not sure and do not know that domain well…

More precisely:
the import matplotlib seems to work well (I can use matplotlib.use('Qt5agg') for example)
but then what causes an error (in the geosoft environment) is for example:

from matplotlib import pyplot
The message I get in Oasis Montaj is the following:
module'matplotlib' has no attribute 'pyplot'

the same is happening with PyQt5. I can import PyQt5 but not use from PyQt5.QtGui import QIcon for example

If you can give me any advice or help, it will be very welcome!


  • Hello,
    I'm stuck with this import limitation.

    Does anybody already encountered some problem using some package in a gx extension?

    Thanks again for help
  • Not very elegant, but handled the problem using a wrapper py file like that:

    def rungx():
    os.system(r'py -3.6 "Pathtomypyfile.py"')

    this prevent me from having some path definition problem and ensures my python file is working the same way either launched from geosoft menu or from spyder.
This discussion has been closed.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!