[Qgis-developer] Import error in the qgis.core, qgis.gui
module, Help needed
sonai1978
to_banerjee at rediffmail.com
Thu Sep 4 10:32:36 EDT 2008
Dear Aaron,
Thnak you very much for your reply. I have already tried that. Copying qgis
directory inside the site packages. But then i get the dll error. I think i
am missing something in between which is causing the error.
I dont know what to do next.
Please help me out.
Thank u in advance.
Bye and take care
Bishwarup
Aaron Racicot-2 wrote:
>
> Try adding the path to the python directory within your QGIS install to
> your
> PYTHONPATH environment variable. Something like:
>
>
>
> PYTHONPATH=C:\Python25\Lib\site-packages;C:\Program Files\Quantum GIS
> 0_11_0\python
>
>
>
> The other option is to copy the qgis dir from the python folder in your
> QGIS
> install into site-packages manually. but I prefer setting the PYTHONPATH.
>
>
>
> Once you think you have things set up you can just try to launch a cmd
> shell
> and test the import:
>
>
>
> C:\Users\Xxxx>python
>
> Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit
> (Intel)]
> on win32
>
> Type "help", "copyright", "credits" or "license" for more information.
>
>>>> from qgis.core import *
>
>
>
> Hope that helps.
>
>
>
> Aaron
>
>
>
> From: qgis-developer-bounces at lists.osgeo.org
> [mailto:qgis-developer-bounces at lists.osgeo.org] On Behalf Of Bishwarup
> Banerjee
> Sent: Wednesday, September 03, 2008 11:09 PM
> To: qgis-developer at lists.osgeo.org
> Subject: [Qgis-developer] Import error in the qgis.core, qgis.gui module,
> Help needed
>
>
>
> Hi,
>
> I am a newbie in this environment (python, QGIS). For last few days i
> have
> been trying hard to compile and execute the tutorial of TIM written in
> python. But i am getting some error or other.
>
> The code is as follows
>
>
>
>
>
>
>
>
> import sys
> import os
>
>
> from PyQt4.QtCore import *
> from PyQt4.QtGui import *
> from qgis.core import *
> from qgis.gui import *
> #from F:\Python25\Lib\site-packages\qgis import core as QgsCore
> #from F:\Python25\Lib\site-packages\qgis import gui as QgsGui
>
> # Import our GUI
> from mainwindow_ui import Ui_MainWindow
> # Import our resources (icons)
> import resources
> # Environment variable QGISHOME must be set to the install directory
> # before running this application
> qgis_prefix = os.getenv("QGISHOME")
> class MainWindow(QMainWindow, Ui_MainWindow):
>
> def __init__(self):QMainWindow.__init__(self)
>
> # Required by Qt4 to initialize the UI
> self.setupUi(self)
>
> # Set the title for the app
> self.setWindowTitle("BTC C-DAC v 1.0")
> # Create the map canvas
> self.canvas = QgsMapCanvas()
> # Set the background color to light blue something
> self.canvas.setCanvasColor(QColor(200,200,255))
> self.canvas.enableAntiAliasing(True)
> self.canvas.useQImageToRender(False)
> self.canvas.show()
>
> # Lay our widgets out in the main window using a
> # vertical box layout
> self.layout = QVBoxLayout(self.frame)
> self.layout.addWidget(self.canvas)
>
> # Create the actions for our tools and connect each to the appropriate
> # method
> self.actionAddLayer = QAction(QIcon(":/foss4g2007/mActionAddLayer.png"),
> "Add Layer", self.frame)
>
> self.connect(self.actionAddLayer, SIGNAL("activated()"), self.addLayer)
> self.actionZoomIn = QAction(QIcon(":/foss4g2007/mActionZoomIn.png"),
> "Zoom
> In", self.frame)
> self.connect(self.actionZoomIn, SIGNAL("activated()"), self.zoomIn)
> self.actionZoomOut = QAction(QIcon(":/foss4g2007/mActionZoomOut.png"),
> "Zoom Out", self.frame)
> self.connect(self.actionZoomOut, SIGNAL("activated()"), self.zoomOut)
> self.actionPan = QAction(QIcon(":/foss4g2007/mActionPan.png"), "Pan",
> self.frame)
> self.connect(self.actionPan, SIGNAL("activated()"), self.pan)
> self.actionZoomFull =
> QAction(QIcon(":/foss4g2007/mActionZoomFullExtent.png"), "Zoom Full
> Extent",
>
> self.frame)
> self.connect(self.actionZoomFull, SIGNAL("activated()"),
> self.zoomFull)
>
> # Create a toolbar
> self.toolbar = self.addToolBar("Map")
> # Add the actions to the toolbar
> self.toolbar.addAction(self.actionAddLayer)
> self.toolbar.addAction(self.actionZoomIn)
> self.toolbar.addAction(self.actionZoomOut);
> self.toolbar.addAction(self.actionPan);
> self.toolbar.addAction(self.actionZoomFull);
>
> # Create the map tools
> self.toolPan = QgsMapToolPan(self.canvas)
> self.toolZoomIn = QgsMapToolZoom(self.canvas, False) # false = in
> self.toolZoomOut = QgsMapToolZoom(self.canvas, True) # true = out
> # Set the map tool to zoom in
> def zoomIn(self):
> self.canvas.setMapTool(self.toolZoomIn)
>
> # Set the map tool to zoom out
> def zoomOut(self):
> self.canvas.setMapTool(self.toolZoomOut)
>
> # Set the map tool to
> def pan(self):
> self.canvas.setMapTool(self.toolPan)
>
> # Zoom to full extent of layer
> def zoomFull(self):
> self.canvas.zoomFullExtent()
> # Add an OGR layer to the map
> def addLayer(self):
> file = QFileDialog.getOpenFileName(self, "Open Shapefile", ".",
> "Shapefiles(*.shp)")
>
> fileInfo = QFileInfo(file)
>
> # Add the layer
> layer = QgsVectorLayer(file, fileInfo.fileName(), "ogr")
>
> #if not layer.isValid():
> #return
>
> # Change the color of the layer to gray
> symbols = layer.renderer().symbols()
> symbol = symbols[0]
> symbol.setFillColor(QColor.fromRgb(192,192,192))
>
> # Add layer to the registry
> QgsMapLayerRegistry.instance().addMapLayer(layer);
>
> # Set extent to the extent of our layer
> self.canvas.setExtent(layer.extent())
>
> # Set up the map canvas layer set
> cl = QgsMapCanvasLayer(layer)
> layers = [cl]
> self.canvas.setLayerSet(layers)
>
> def main(argv):
> # create Qt application
> app = QApplication(argv)
>
> # Initialize qgis libraries
> QgsApplication.setPrefixPath(qgis_prefix, True)
> QgsApplication.initQgis()
>
> # create main window
> wnd = MainWindow()
>
> # Move the app window to upper left
> wnd.move(100,100)
> wnd.show()
>
> # run!
> retval = app.exec_()
>
> # exit
> QgsApplication.exitQgis()
> sys.exit(retval)
>
>
> if __name__ == "__main__":
> main(sys.argv)
>
>
>
> Previously i was getting the error
>
> No module named PyQt4.QtCore and PyQt4.QtGui
>
> But after installing the PyQt inside the site package it is not
> showing any error now.
>
>
> Now i have started getting the error,
> qgis. core module not found.
> qgis.gui module not found.
>
> I have done whatever way possible from my side.
>
> My system environment is as follows:
>
> OS -- Windows 2000
> Python 2.5
> PyQt 4.4.3.1
> QGIS 0.11.0.2
>
> I dont know in which step i should be installing these one after other.
> and also where to install and how to compile
>
> It will be very kind of you if you can help me out.
>
> Bye
> Sonai
>
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>
>
--
View this message in context: http://www.nabble.com/Import-error-in-the-qgis.core%2C-qgis.gui-module%2C-Help-needed-tp19303959p19309673.html
Sent from the qgis-developer mailing list archive at Nabble.com.
More information about the Qgis-developer
mailing list