Project

General

Profile

cdo.py does not work

Added by Joey Molenk over 6 years ago

Dear All,

My cdo 1.7.0-cygwin64-static works perfectly on Windows using Cygwin.
But when I try import cdo in Python it does not work. I have the cdo.py version 1.3.5 running on Python 2.7.8.
I have a Windows 10 PC with 64-bit system.

The cdo.exe file is in e:\dev\cdo

This is the error message from the python console:

>>> from cdo import *
>>> cdo = Cdo()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\ArcGIS10.3\lib\site-packages\cdo.py", line 97, in __init__
    self.operators              = self.getOperators()
  File "C:\Python27\ArcGIS10.3\lib\site-packages\cdo.py", line 314, in getOperators
    endI = ops.index('')
ValueError: '' is not in list

or

>>> import cdo
>>> cdo = Cdo()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'Cdo' is not defined

Thank you in advance for any help.

Joey


Replies (8)

RE: cdo.py does not work - Added by Ralf Mueller over 6 years ago

hi Joey

have you checkes

c = cdo.Cdo()

do you use python within cygwin or directly on win10?

cheers
ralf

RE: cdo.py does not work - Added by Joey Molenk over 6 years ago

Dear Ralf,

Thank you for your reply.

I'm using python within cygwin.

I tried c = cdo.Cdo()
but unfortunately I got the same error as above: [ValueError: '' is not in list]

I'm wondering if the problem could be the fact that my cdo is in [e:\dev\cdo] instead of somewhere in [c:\] ?

Best regards,

Joey

RE: cdo.py does not work - Added by Ralf Mueller over 6 years ago

can you check the latest cdo version for cygwin?

RE: cdo.py does not work - Added by Joey Molenk over 6 years ago

I have been working with cdo 1.7.0-cygwin64-static with no problems within cygwin.

After installing the latest version (cdo-1.9.0-cygwin64) it works, but does not display any information in the cygwin console when running commands (e.g. cdo -V). I have installed all the necessary modules and verified that cdo works by using e.g. cdo copy ifile ofile.

I tested also cdo-1.7.2-cygwin64 and cdo-1.8.2-cygwin64, and the same, they do not display any information in the cygwin console.

Please, could someone provide some advice on this issue of not displaying any information in the screen.

Thank you a million,

Joey

RE: cdo.py does not work - Added by Ralf Mueller over 6 years ago

Hi Joey!

I installed a fresh Windows10 and put a cygwin-64bit system into it. Than I took the 1.9.2 cygwin binary and put it into the /bin directory within cygwin (i.e. C:\cygwin64\bin under win10). With the additinal libs (netcdf/proj/udunits2) installed it worked without problems

the development version and the 1.3.5 release of cdo.py work with that CDO binary

There is little bug in there: the cdo-1.9.2-cygwin binary package actually contains cdo-1.9.0, but this doesn't harm in this context.

hth
ralf

RE: cdo.py does not work - Added by Ralf Mueller over 6 years ago

BTW

in your initial message, you seem to use windows-based python instead of cygwin-based python. Calling the cygwin-based CDO binary from the windows-based python is something I don't expect to work. I would stick to cygwin only

RE: cdo.py does not work - Added by Joey Molenk over 6 years ago

Dear Ralf,

Problem fixed !!
Thank you for your support. Included a summary of steps done:

System:
Windows 10 PC with 64-bit system, Python 2.7.8, Cygwin 2.9.0-3

Steps:

1) Install in cygwin the following packages using setup-x86_64.exe:
netcdf
udunits
libproj
libgomp
libudunits

2) Install cdo 1.9.0 (from cdo-1.9.0-cygwin64.zip)
In cygwin use:

./cdo.exe

Then copy cdo.exe in ..\cygwin64\bin

3) For using cdo 1.9.0 without problems in cygwin, launch cygwin using Minnty:
in the cygwin desktop icon target set: E:\dev\cygwin64\bin\mintty.exe -i /Cygwin-Terminal.ico -

4) Install cdo.py using pip (I installed cdo.py 1.3.5)

5) The first two lines of the python script must be:

import cdo
c = cdo.Cdo()

or

from cdo import *
cdo = Cdo()

All the best,

Joey

RE: cdo.py does not work - Added by Guobao Song over 6 years ago

Joey Molenk wrote:

Dear All,

My cdo 1.7.0-cygwin64-static works perfectly on Windows using Cygwin.
But when I try import cdo in Python it does not work. I have the cdo.py version 1.3.5 running on Python 2.7.8.
I have a Windows 10 PC with 64-bit system.

The cdo.exe file is in e:\dev\cdo

This is the error message from the python console:

[...]

or

[...]

Thank you in advance for any help.

Joey

Dear Joey

Can you call cdo from other python IDI? such as in Spyder?

Thank and kind regards,

Guobao

    (1-8/8)