1

A similar problem with the python gdal module Gdal will not import after several installs (Mac OSX) was solved by modifying my shell profile to ensure MacPorts-installed ports are found, and then using sudo port select python python27.

But this time it's every module in my graphics folder that deals with tiff and png reading and writing that will not import:

tiff @3.9.5 graphics/tiff

pngpp @0.2.3 graphics/pngpp

libgeotiff @1.3.0 graphics/libgeotiff

Again, when I run python to import either module I get the similar response:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named png

What am I doing wrong?

Community
  • 1
  • 1
Alvin
  • 357
  • 1
  • 3
  • 11
  • Did you create the `graphics` folder yourself? – Constantinius Aug 18 '11 at 16:36
  • why cant you use PIL or another imaging repository? – Jim Aug 18 '11 at 16:58
  • @Constantinius I didn't create the folder. It was created by macports when I installed the modules. – Alvin Aug 18 '11 at 17:05
  • @Jim PIL only handles reading of png, but not geotiff. I am using satellite imagery and want to maintain the geospatial tags when I read and write to files. Thanks guys. – Alvin Aug 18 '11 at 17:06
  • So, if gdal is working, why cant't you use that one for image manipulation? – Constantinius Aug 18 '11 at 18:13
  • @Constanitinius gdal is working but it only has an open (read only) utility; no ability to write Tiffs/GeoTiffs. Am I wrong? – Alvin Aug 18 '11 at 18:16
  • @Constanitinius, the only file I/O that I can find in gdal: Help on built-in function Open in module _gdal: Open(...) Open(char name, GDALAccess eAccess = GA_ReadOnly) -> Dataset (END) – Alvin Aug 18 '11 at 18:19
  • You posted this exact question yesterday. Don't re-post a question just because you don't get an answer, edit the question with more information to bump it to the top of the active page. – agf Aug 19 '11 at 16:29

1 Answers1

1

For most Python packages, MacPorts has separate ports available for each supported Python version. For example, if you are trying to use PIL (the Python Imaging Library), you need to install the 2.7 version of that port:

sudo port install py27-pil

That will also install the MacPorts version of Python 2.7, if you don't already have it installed. It is located at /opt/local/bin/python2.7.

Ned Deily
  • 83,389
  • 16
  • 128
  • 151