miniconda python3.6 and CDO
Added by Francois Delage almost 7 years ago
Heya,
I am trying to use CDO in miniconda 3, i have a really simple python test program (test_cdo.py) :
from cdo import *
import os
cdo = Cdo()
os.system('which cdo')
cdo.yearmean(options='-h')
but I get that :
/g/data/eg3/pfd548/miniconda/envs/py3.6_basic/bin/cdo
Error in calling operator yearmean with:
cdo -O -h yearmean /short/eg3/pfd548/tmp/cdoPy5mpftcnq<<<
STDOUT:
STDERR:/bin/sh: cdo: command not found
Traceback (most recent call last):
File "test_cdo.py", line 5, in <module>
cdo.yearmean(options='-h')
File "/g/data/eg3/pfd548/miniconda/envs/py3.6_basic/lib/python3.6/site-packages/cdo.py", line 255, in get
raise CDOException(**retvals)
cdo.CDOException: (returncode:127) /bin/sh: cdo: command not found
Anybody knows what could go wrong, I also tried to install with python2.7 with no success.
Thanks,
Francois
Replies (4)
RE: miniconda python3.6 and CDO - Added by Ralf Mueller almost 7 years ago
can you check, if you could run cdo within your conda environment?
RE: miniconda python3.6 and CDO - Added by Francois Delage almost 7 years ago
Hey Ralph,
I can use cdo within my conda environment and it works perfectly fine from the command line using the miniconda cdo executable located in /g/data/eg3/pfd548/miniconda/envs/py3.6_basic/bin/cdo.
I have been a longterm user of cdo but through command line and shell scripts. I am really interested in using the python version.
Francois
RE: miniconda python3.6 and CDO - Added by Ralf Mueller almost 7 years ago
please give this a try:
from cdo import * cdo = Cdo('/g/data/eg3/pfd548/miniconda/envs/py3.6_basic/bin/cdo') cdo.debug = True print(cdo.operators) cdo.topo('r10x10',options='-f nc',output='t.nc')
This prints a long list of operators and creates the t.nc topo file. It runs smoothly in my miniconda2 environment (with a slight change to the cdo path, of cause)
RE: miniconda python3.6 and CDO - Added by Francois Delage almost 7 years ago
Hey Ralf,
I used your script and i got it to work with miniconda3 but i had to modify the cdo.py file and add this line
cmd[0]='/g/data/eg3/pfd548/miniconda/envs/py3.6_basic/bin/cdo'
after line 249.
It's not ideal, I am not sure why the cdo command is not built properly but it seems to be working.
Francois