Import error in the qgis.core, qgis.gui module, Help needed

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

Import error in the qgis.core, qgis.gui module, Help needed

Bishwarup Banerjee
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
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

RE: Import error in the qgis.core, qgis.gui module, Help needed

Aaron Racicot

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: [hidden email] [mailto:[hidden email]] On Behalf Of Bishwarup Banerjee
Sent: Wednesday, September 03, 2008 11:09 PM
To: [hidden email]
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
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Import error in the qgis.core, qgis.gui module, Help needed

Marco Pasetti
Hi all,

>>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.

>Try adding the path to the python directory within your QGIS install to
>your PYTHONPATH environment variable.

The Quantum GIS package for windows comes with all the files (QT and Python)
needed to execute the python plugins, but if you want to develop new python
applications within QGIS you probablly would need more libraries than the
ones bundled in the current distributed package. This said, if you installed
Python on your windows machine you should not need anything else, because
python itself set its python environmental variable during the install
procedure. If you're encountering some errors with Python, that may be
generated by different problems that would need to be more accurately
investigated. You'r referring to a "Tim's tutorial", what exactly?

Regards,

Marco Pasetti


_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

RE: Import error in the qgis.core, qgis.gui module, Help needed

sonai1978
In reply to this post by Aaron Racicot
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@lists.osgeo.org
[mailto:qgis-developer-bounces@lists.osgeo.org] On Behalf Of Bishwarup
Banerjee
Sent: Wednesday, September 03, 2008 11:09 PM
To: qgis-developer@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@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

RE: Import error in the qgis.core, qgis.gui module, Help needed

Aaron Racicot
Just add the QGIS install dir to your system path to get rid of the DLL
errors.

A

-----Original Message-----
From: [hidden email]
[mailto:[hidden email]] On Behalf Of sonai1978
Sent: Thursday, September 04, 2008 7:33 AM
To: [hidden email]
Subject: RE: [Qgis-developer] Import error in the qgis.core, qgis.gui
module, Help needed


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


_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

RE: Import error in the qgis.core, qgis.gui module, Help needed

sonai1978
Dear Aaron,

I did the same way u suggested i still get the following error

*******************
>>> import sys
>>> sys.path
['F:\\Python25\\Lib\\idlelib', 'C:\\WINNT\\system32\\python25.zip', 'F:\\Python25\\DLLs', 'F:\\Python25\\lib', 'F:\\Python25\\lib\\plat-win', 'F:\\Python25\\lib\\lib-tk', 'F:\\Python25', 'F:\\Python25\\lib\\site-packages']
>>> import qgis.core

Traceback (most recent call last):
  File "<pyshell#2>", line 1, in <module>
    import qgis.core
ImportError: DLL load failed: The specified module could not be found.


************************
Second portion

*************************

>>> sys.path
['F:\\Python25\\Lib\\idlelib', 'C:\\WINNT\\system32\\python25.zip', 'F:\\Python25\\DLLs', 'F:\\Python25\\lib', 'F:\\Python25\\lib\\plat-win', 'F:\\Python25\\lib\\lib-tk', 'F:\\Python25', 'F:\\Python25\\lib\\site-packages']
>>> import gqis.core

Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    import gqis.core
ImportError: No module named gqis.core
>>> from qgis.core import *

Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
    from qgis.core import *
ImportError: DLL load failed: The specified module could not be found.

***********************
The first portion of the error when i copied the qgis dir inside site package.

The second portion of error is when i added the pythonpath variable.

I have installed python in my F: drive
as F:\python25

and Quantum GIS 0.11.0.2 in F:\Quantum GIS.

it will be very helpful if you can find a solution to my problem.
Bye and take care

Bishwarup




Aaron Racicot-2 wrote
Just add the QGIS install dir to your system path to get rid of the DLL
errors.

A

-----Original Message-----
From: qgis-developer-bounces@lists.osgeo.org
[mailto:qgis-developer-bounces@lists.osgeo.org] On Behalf Of sonai1978
Sent: Thursday, September 04, 2008 7:33 AM
To: qgis-developer@lists.osgeo.org
Subject: RE: [Qgis-developer] Import error in the qgis.core, qgis.gui
module, Help needed


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


_______________________________________________
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Import error in the qgis.core, qgis.guimodule, Help needed

Marco Pasetti
Hi Bishwarup,

> I did the same way u suggested i still get the following error
>
> *******************
>>>> import sys
>>>> sys.path
> ['F:\\Python25\\Lib\\idlelib', 'C:\\WINNT\\system32\\python25.zip',
> 'F:\\Python25\\DLLs', 'F:\\Python25\\lib', 'F:\\Python25\\lib\\plat-win',
> 'F:\\Python25\\lib\\lib-tk', 'F:\\Python25',
> 'F:\\Python25\\lib\\site-packages']
>>>> import qgis.core
>
> Traceback (most recent call last):
>  File "<pyshell#2>", line 1, in <module>
>    import qgis.core
> ImportError: DLL load failed: The specified module could not be found.
>
>
> ************************
> Second portion
>
> *************************
>
>>>> sys.path
> ['F:\\Python25\\Lib\\idlelib', 'C:\\WINNT\\system32\\python25.zip',
> 'F:\\Python25\\DLLs', 'F:\\Python25\\lib', 'F:\\Python25\\lib\\plat-win',
> 'F:\\Python25\\lib\\lib-tk', 'F:\\Python25',
> 'F:\\Python25\\lib\\site-packages']
>>>> import gqis.core
>
> Traceback (most recent call last):
>  File "<pyshell#4>", line 1, in <module>
>    import gqis.core
> ImportError: No module named gqis.core
>>>> from qgis.core import *
>
> Traceback (most recent call last):
>  File "<pyshell#5>", line 1, in <module>
>    from qgis.core import *
> ImportError: DLL load failed: The specified module could not be found.
>
> ***********************
> The first portion of the error when i copied the qgis dir inside site
> package.
>
> The second portion of error is when i added the pythonpath variable.
>
> I have installed python in my F: drive
> as F:\python25
>
> and Quantum GIS 0.11.0.2 in F:\Quantum GIS.

Where is your python script? I suggest you to put it into F:\Quantum
GIS\python\plugins

The Python and PyQt libraries bundled within qgis 0.11.0-x are: Python 2.5.2
and PyQt 4.4.2
Different Python and PyQt version installed libraries may cause errors if
the python script is launched outside the qgis tree (dir and subdirs)

Regards,

Marco

_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Import error in the qgis.core, qgis.gui module, Help needed

Tim Sutton
In reply to this post by Bishwarup Banerjee
Hi

2008/9/4 Bishwarup Banerjee <[hidden email]>:
> 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.

Just a correction on this, Martin Dobias wrote the python tutorials, not me.

Regards

--
Tim Sutton - QGIS Project Steering Committee Member (Release Manager)
==============================================
Visit http://linfiniti.com to find out about:
 * QGIS programming services
 * Mapserver and PostGIS based hosting plans
 * FOSS Consulting Services
Skype: timlinux Irc: timlinux on #qgis at freenode.net
==============================================
_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Import error in the qgis.core, qgis.gui module, Help needed

sonai1978

The error still remains, I tried withthe possible ways but same error.

Marco one thing do i need to get PyQT and python installed if i am having recent Quantum GIS installer.

If yes then in which order i need to get them installed.
If no, then how to run the python script.
Do i need to do any change in the configuration files.

Thanks in advance.

Thanks Tim for getting me corrected.

I found the tutorial on your blog, so i thought so. Anyway Thanks to all the members for creating a software.

Bye and take care
Bishwarup




Tim Sutton wrote
Hi

2008/9/4 Bishwarup Banerjee <bishwarup.banerjee@gmail.com>:
> 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.

Just a correction on this, Martin Dobias wrote the python tutorials, not me.

Regards

--
Tim Sutton - QGIS Project Steering Committee Member (Release Manager)
==============================================
Visit http://linfiniti.com to find out about:
 * QGIS programming services
 * Mapserver and PostGIS based hosting plans
 * FOSS Consulting Services
Skype: timlinux Irc: timlinux on #qgis at freenode.net
==============================================
_______________________________________________
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Import error in the qgis.core, qgis.gui module, Help needed

Ervin
In reply to this post by Bishwarup Banerjee

Bishwarup Banerjee wrote
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@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Hi there,

I'm also having trouble with the example given above. The error message I got is:

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    import qgis.core
ImportError: DLL load failed: The specified procedure could not be found.

I have installed python 2.5.2 in C:\Python25 and Qgis 1.0 installed from the package OSGeo4W in the default dir C:\OSGeo4W.

The environment variables are set as below:

PATH = C:\OSGeo4W\apps\qgis;%PATH%
PYTHONPATH = C:\OSGeo4W\apps\python25\lib\site-packages
QGISHOME = C:\OSGeo4W\apps\qgis

I also tried to add to the path variable the following dirs:
C:\OSGeo4W\bin; C:\OSGeo4W\apps\qgis\bin

but still no result.

I would really appreciate any help!

Many thanks in advance,

Ervin
Reply | Threaded
Open this post in threaded view
|

Re: Import error in the qgis.core, qgis.gui module, Help needed

Jürgen E. Fischer
Hi Ervin,

On Sat, 25. Apr 2009 at 04:10:56 -0700, Ervin wrote:
> I have installed python 2.5.2 in C:\Python25 and Qgis 1.0 installed
> from the package OSGeo4W in the default dir C:\OSGeo4W.

Double check that you're using OSGeo4W's python and nothing from the one
in C:\Python25.


Jürgen

--
Jürgen E. Fischer         norBIT GmbH               Tel. +49-4931-918175-20
Dipl.-Inf. (FH)           Rheinstraße 13            Fax. +49-4931-918175-50
Software Engineer         D-26506 Norden               http://www.norbit.de

--
norBIT Gesellschaft fuer Unternehmensberatung und Informationssysteme mbH
Rheinstrasse 13, 26506 Norden
GF: Jelto Buurman, HR: Amtsgericht Emden, HRB 5502

_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Import error in the qgis.core, qgis.gui module, Help needed

Ervin

Jürgen E. Fischer wrote
Hi Ervin,

On Sat, 25. Apr 2009 at 04:10:56 -0700, Ervin wrote:
> I have installed python 2.5.2 in C:\Python25 and Qgis 1.0 installed
> from the package OSGeo4W in the default dir C:\OSGeo4W.

Double check that you're using OSGeo4W's python and nothing from the one
in C:\Python25.


Jürgen

--
Jürgen E. Fischer         norBIT GmbH               Tel. +49-4931-918175-20
Dipl.-Inf. (FH)           Rheinstraße 13            Fax. +49-4931-918175-50
Software Engineer         D-26506 Norden               http://www.norbit.de

--
norBIT Gesellschaft fuer Unternehmensberatung und Informationssysteme mbH
Rheinstrasse 13, 26506 Norden
GF: Jelto Buurman, HR: Amtsgericht Emden, HRB 5502

_______________________________________________
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Hi Jürgen,

Thanks for your reply, but I don't get your idea. Do you mean that I have to include into the path variable only the C:\OSGeo4W dir?
Please explain more (if you can)

Ervin.
Reply | Threaded
Open this post in threaded view
|

Re: Import error in the qgis.core, qgis.gui module, Help needed

Giovanni Manghi

> Hi Jürgen,
>
> Thanks for your reply, but I don't get your idea. Do you mean that I have to
> include into the path variable only the C:\OSGeo4W dir?
> Please explain more (if you can)

I had once a similar problem and I noticed that if pyhton is already
installed this interferes with the osgeo4w installation.

I removed it, installed what I needed via osgeo4w, including python,
than re-installed pyhton and all worked fine. I don't know if there is a
simpler workaround.

See also:

http://trac.osgeo.org/osgeo4w/ticket/65#comment:11


-- Giovanni --

_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Import error in the qgis.core, qgis.gui module, Help needed

Ervin

Giovanni Manghi wrote
I had once a similar problem and I noticed that if pyhton is already
installed this interferes with the osgeo4w installation.

I removed it, installed what I needed via osgeo4w, including python,
than re-installed pyhton and all worked fine. I don't know if there is a
simpler workaround.

See also:

http://trac.osgeo.org/osgeo4w/ticket/65#comment:11


-- Giovanni --

_______________________________________________
Qgis-developer mailing list
Qgis-developer@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-developer
Hi Giovanni,

I tried that, but no success at all,  thanks anyway.

Ervin
Reply | Threaded
Open this post in threaded view
|

Re: Import error in the qgis.core, qgis.gui module, Help needed

Tim Sutton-4
In reply to this post by Ervin
Hi
On 25 Apr 2009, at 1:10 PM, Ervin wrote:

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.

Hi just to give due credit, the python version of the tutorial was written by Martin Dobias, not myself.

Regards

Tim

_______________________________________________
Qgis-developer mailing list
[hidden email]
http://lists.osgeo.org/mailman/listinfo/qgis-developer