Opened 5 years ago

Closed 4 years ago

#231 closed defect (fixed)

Cannot import osgeo, gdal , ogr libraries in Python Console

Reported by: venka Owned by: Jeff McKenna
Priority: major Milestone: 4.0.2 release
Component: MS4W - Python Version: 4.0.1
Keywords: Python Console, OSGeo, gdal, ogr Cc:
Blocked By: Blocking:

Description

Opened command window and ran setenv.bat, changed to C:\ms4w\Python
and ran python.exe.

Cannot import osgeo, gdal etc in Python Shell.
(See attached image).

Venka

Attachments (1)

python_console.PNG (58.7 KB ) - added by venka 5 years ago.
failed import from osgeo gdal

Download all attachments as: .zip

Change History (7)

by venka, 5 years ago

Attachment: python_console.PNG added

failed import from osgeo gdal

comment:1 by venka, 5 years ago

Copying the C:\ms4w\gdalbindings\python\gdal\osgeo directory to
C:\ms4w\Python\Lib\site-packages resolves this issue.

The above step also makes copying C:\ms4w\gdalbindings\python\gdal\osgeo
to C:\ms4w\Apache\cgi-bin (see https://ms4w.com/trac/ticket/223) redundant.

I think the gdal Python bindings (as well as other Python bindings)
could better be stored in the C:\ms4w\Python\Lib\site-packages directory

comment:2 by Jeff McKenna, 5 years ago

Resolution: wontfix
Status: newclosed

This issue was fixed through ticket #223 and included in MS4W 4.0.1 release

What version of MS4W are you running? (mapserv -v)

Indeed, your steps in this ticket are indeed redundant, as this was fixed in the recent MS4W 4.0.1 release

Marking ticket as "won't fix". If you can test with MS4W 4.0.1 from now on that would be great.

Last edited 5 years ago by Jeff McKenna (previous) (diff)

comment:3 by Jeff McKenna, 5 years ago

Other notes:

  • After you setenv.bat you don't need to change directory, you can execute "python -v" (or any MS4W tool) in that same directory, or any directory (because setenv.bat changes your PATH)
  • if you find a problem with a fixed ticket (example issue # 223) you should re-open the ticket and add your comment. (instead of opening a new ticket, and providing feedback on an older version). Sorry.

comment:4 by niroshan, 5 years ago

Hello there,

I would like to inform you that I have the same situation as described in #231 ticket.
Even we run the setenv.bat we cannot import gdal from python CMD.

Also I have edited the setenv.bat and tried, what has done is;

added the following line;

C:\ms4w\gdalbindings\python\gdal\osgeo

it also did not work.

So finally osgeo folder has been copied to the site-packages directory from C:\ms4w\gdalbindings\python\gdal\osgeo.

After that we can import gdal from both python cmd and apache cgi-bin.
We don't need a osgeo folder inside cgi-bin ( MS4W 4.0.1 version) when you have a osgeo directory
in site-packages. It solved the both issues.

As per the above report it seems it need to be fixed, otherwise we cannot use python inside the ms4w. Also we have many osgeo directories in several locations.

Best
Niro

comment:5 by niroshan, 5 years ago

Resolution: wontfix
Status: closedreopened

comment:6 by Jeff McKenna, 4 years ago

Resolution: fixed
Status: reopenedclosed

Thanks for the feedback. MS4W 4.0.2 is now available (- included in MS4W 4.0.2 release https://ms4w.com/download.html), and the GDAL Python module is moved into /Python/Lib/site-packages/

To test, here are the steps:

  open Command window
  cd C:/ms4w
  setenv.bat
  python -c "from osgeo import gdal"

No error message should be displayed.

Note: See TracTickets for help on using tickets.