I am writing a simple standalone QGis application. My code is like this:

class MainForm(QtGui.QMainWindow, Ui_MainWindow):
    def __init__(self):
        super(MainForm, self).__init__()

        assert self.canvas_crs.isValid()

The Python script works pretty well. Then I built .EXE package using pyinstaller, and the .exe package works well too within the OSGeo4W64 environment. However, once I move the package into another computer without OSGeo4W64 environment, it stops working. The Cmd error message shows that something seems to be wrong with QgsCoordinateReferenceSystem:

Qt: Untested Windows version 10.0 detected!
Running In An Application Bundle
Error in sys.excepthook:
Traceback (most recent call last):
  File "qgis\utils.py", line 196, in qgis_excepthook
  File "qgis\utils.py", line 107, in showException
  File "qgis\utils.py", line 142, in open_stack_dialog
AttributeError: 'NoneType' object has no attribute 'messageBar'

Original exception was:
Traceback (most recent call last):
  File "CallMainWin.py", line 324, in <module>
    win = MainForm()
  File "CallMainWin.py", line 49, in __init__
    assert self.canvas_crs.isValid()
[64268] Failed to execute script CallMainWin

If I remove the statement

assert self.canvas_crs.isValid()

from program, it will be working, the map will be displayed in the qgsMapCanvas, except that the CRS of the map is apparently wrong.

Could anyone help me out with this please?

Your Answer

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

Browse other questions tagged or ask your own question.