Project

General

Profile

TypeError: expected str, bytes or os.PathLike object, not NoneType

Added by Bérénice Ferrand over 2 years ago

Hi,

Recently, my computer completely sputtered and I had to uninstall Anaconda, Spyder... from my computer and reinstall everything. I lost all the packages I had installed so cdo.
I have this error : TypeError: expected str, bytes or os.PathLike object, not NoneType
It's link with cdo because when I mask this line, my code stopped but because of the file and no because of cdo. So it is the error.

I tried to do :

pip install cdo
conda install cdo

I'm not sure what to do, but I'm not sure what to do. Anyone have a idea of what I have to run on my terminal to install cdo ?

I am on a Mac and I use Spyder 5.1.5.

Thanks.


Replies (11)

RE: TypeError: expected str, bytes or os.PathLike object, not NoneType - Added by Karin Meier-Fleischer over 2 years ago

You want to use CDO with python, right? Then you have to install python-cdo.

conda install python-cdo

RE: TypeError: expected str, bytes or os.PathLike object, not NoneType - Added by Bérénice Ferrand over 2 years ago

Yes, that is right.

I have this message :

Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

- python-cdo

Current channels:

- https://repo.anaconda.com/pkgs/main/osx-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/osx-64
- https://repo.anaconda.com/pkgs/r/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

https://anaconda.org

and use the search bar at the top of the page.

RE: TypeError: expected str, bytes or os.PathLike object, not NoneType - Added by Bérénice Ferrand over 2 years ago

(in one post, sorry the layout didn't work well)

RE: TypeError: expected str, bytes or os.PathLike object, not NoneType - Added by Bérénice Ferrand over 2 years ago

It seems to be not working, It's been running for hours and I get these kinds of messages:

"Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: -
Found conflicts! Looking for incompatible packages.
This can take several minutes. Press CTRL-C to abort.
Examining conflict for cffi soupsieve jmespath frozenlist shapely numba qtcon/ l
Examining conflict for cffi soupsieve jmespath frozenlist shapely numba qtcon| l
Examining conflict for cffi soupsieve jmespath frozenlist shapely numba qtcon\|
Examining conflict for cffi soupsieve jmespath cfitsio shapely frozenlist num|
Examining conflict for cffi soupsieve jmespath frozenlist shapely numba qtcons|
Examining conflict for cffi soupsieve jmespath frozenlist shapely numba qtcons-
Examining conflict for widgetsnbextension conda-verify conda-build numpy-base| a""

Is it normal ? Should I leave it running again ?

RE: TypeError: expected str, bytes or os.PathLike object, not NoneType - Added by Karin Meier-Fleischer over 2 years ago

It seems to be a conflict with already installed packages. Maybe it is better to install CDO in an own conda environment to see if if that works for you.

conda create -n cdo python-cdo

After the installation has finished activate the conda environment cdo with

conda activate cdo

Run your CDO commands.

If this works for you 👍 Then you can install in the activated environment other packages if needed for your work.

To deactivate the environment

conda deactivate

RE: TypeError: expected str, bytes or os.PathLike object, not NoneType - Added by Bérénice Ferrand over 2 years ago

This time I have this when I run :

conda create -n cdo python-cdo

"Collecting package metadata (current_repodata.json): done
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed

PackagesNotFoundError: The following packages are not available from current channels:

- python-cdo

Current channels:

- https://repo.anaconda.com/pkgs/main/osx-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/osx-64
- https://repo.anaconda.com/pkgs/r/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

https://anaconda.org

and use the search bar at the top of the page."

RE: TypeError: expected str, bytes or os.PathLike object, not NoneType - Added by Karin Meier-Fleischer over 2 years ago

See the description above with '-c conda-forge' from above.

Do this only once (then you do not need to add the '-c conda-forge' part anymore:

conda config --add channels conda-forge

Then create the new cdo environment:

conda create -n cdo python-cdo

See the CDO installation instruction https://code.mpimet.mpg.de/projects/cdo/wiki/Anaconda

See conda User Guide https://docs.conda.io/projects/conda/en/latest/user-guide/index.html

RE: TypeError: expected str, bytes or os.PathLike object, not NoneType - Added by Bérénice Ferrand over 2 years ago

For the moment, cdo seems to be working. I tried to install other packages but I have :

"ValueError: did not find a match in any of xarray's currently installed IO backends ['netcdf4']. Consider explicitly selecting one of the installed engines via the ``engine`` parameter, or installing additional IO dependencies, see:
https://docs.xarray.dev/en/stable/getting-started-guide/installing.html
https://docs.xarray.dev/en/stable/user-guide/io.html"

I tried :

conda install nefCDF4
pip install netCDF4

and other package from the website mentioned, but it is still a fail.

RE: TypeError: expected str, bytes or os.PathLike object, not NoneType - Added by Karin Meier-Fleischer over 2 years ago

For me the following works pretty good:

conda create -n cdo -c conda-forge python-cdo
conda activate cdo
conda install xarray
conda install netcdf4

RE: TypeError: expected str, bytes or os.PathLike object, not NoneType - Added by Bérénice Ferrand over 2 years ago

Still same problem... in any case, thank you for your precious help !

I will keep looking.

    (1-11/11)