My python version is 3.10.6. I want to create an instance of a Cdo object in python (https://pypi.org/project/cdo/).
from cdo import *
cdo = Cdo()
Howerver, I am getting the following error:
/usr/bin/python3.10 /home/iliamous/PycharmProjects/winbank-esg-risk-gis-platform/scratch_work.py
Traceback (most recent call last):
File "/home/iliamous/PycharmProjects/winbank-esg-risk-gis-platform/scratch_work.py", line 209, in <module>
cdo = Cdo()
File "/home/iliamous/.local/lib/python3.10/site-packages/cdo.py", line 190, in __init__
self.operators = self.__getOperators()
File "/home/iliamous/.local/lib/python3.10/site-packages/cdo.py", line 283, in __getOperators
version = parse_version(getCdoVersion(self.CDO))
File "/home/iliamous/.local/lib/python3.10/site-packages/cdo.py", line 78, in getCdoVersion
proc = subprocess.Popen([path2cdo, '-V'], stderr=subprocess.PIPE, stdout=subprocess.PIPE)
File "/usr/lib/python3.10/subprocess.py", line 969, in __init__
self._execute_child(args, executable, preexec_fn, close_fds,
File "/usr/lib/python3.10/subprocess.py", line 1720, in _execute_child
and os.path.dirname(executable)
File "/usr/lib/python3.10/posixpath.py", line 152, in dirname
p = os.fspath(p)
TypeError: expected str, bytes or os.PathLike object, not NoneType
Seems there was an issue with the installation of the package. First, I removed the package by writing in the terminal
pip uninstall cdo
Then, I installed cdo again, this time using the command line
sudo apt-get -y install cdo
For more info check https://installati.one/ubuntu/20.04/cdo/.