Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc5 in position 9: invalid continuation byte #3279

Closed
PPaircas opened this issue May 29, 2024 · 10 comments
Labels
bug Something isn't working
Milestone

Comments

@PPaircas
Copy link

Description of the problem

import pygmt
pygmt.show_versions()

PyGMT information:
version: v0.12.0
System information:
python: 3.12.3 | packaged by conda-forge | (main, Apr 15 2024, 18:20:11) [MSC v.1938 64 bit (AMD64)]
executable: d:\Program Files\Anaconda\envs\pygmt\python.exe
machine: Windows-11-10.0.22631-SP0
Dependency information:
numpy: 1.26.4
pandas: 2.2.2
xarray: 2024.5.0
netCDF4: 1.6.5
packaging: 24.0
contextily: None
geopandas: None
ipython: None
rioxarray: None
ghostscript: 10.03.1
GMT library information:
binary version: 6.5.0
cores: 8
grid layout: rows
image layout:
library path: D:/Program Files/Anaconda/envs/pygmt/Library/bin/gmt.dll
padding: 2
plugin dir: D:/Program Files/Anaconda/envs/pygmt/Library/bin/gmt_plugins
share dir: D:/Program Files/Anaconda/envs/pygmt/Library/share/gmt
version: 6.5.0PyGMT information:
version: v0.12.0
System information:
python: 3.12.3 | packaged by conda-forge | (main, Apr 15 2024, 18:20:11) [MSC v.1938 64 bit (AMD64)]
executable: d:\Program Files\Anaconda\envs\pygmt\python.exe
machine: Windows-11-10.0.22631-SP0
Dependency information:
numpy: 1.26.4
pandas: 2.2.2
xarray: 2024.5.0
netCDF4: 1.6.5
packaging: 24.0
contextily: None
geopandas: None
ipython: None
rioxarray: None
ghostscript: 10.03.1
GMT library information:
binary version: 6.5.0
cores: 8
grid layout: rows
image layout:
library path: D:/Program Files/Anaconda/envs/pygmt/Library/bin/gmt.dll
padding: 2
plugin dir: D:/Program Files/Anaconda/envs/pygmt/Library/bin/gmt_plugins
share dir: D:/Program Files/Anaconda/envs/pygmt/Library/share/gmt
version: 6.5.0

grid = pygmt.datasets.load_earth_relief(resolution="01d")

"name": "UnicodeDecodeError",
"message": "'utf-8' codec can't decode byte 0xc5 in position 9: invalid continuation byte",
"stack": "---------------------------------------------------------------------------

Minimal Complete Verifiable Example

No response

Full error message

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc5 in position 9: invalid continuation byte

System information

UnicodeDecodeError                        Traceback (most recent call last)
Cell In[12], line 1
----> 1 grid = pygmt.datasets.load_earth_relief(resolution=\"01d\",data_source=\"gebco\")

File d:\\Program Files\\Anaconda\\envs\\pygmt\\Lib\\site-packages\\pygmt\\helpers\\decorators.py:773, in kwargs_to_strings.<locals>.converter.<locals>.new_module(*args, **kwargs)
    770             bound.arguments[\"kwargs\"][arg] = newvalue
    772 # Execute the original function and return its output
--> 773 return module_func(*bound.args, **bound.kwargs)

File d:\\Program Files\\Anaconda\\envs\\pygmt\\Lib\\site-packages\\pygmt\\datasets\\earth_relief.py:168, in load_earth_relief(resolution, region, registration, data_source, use_srtm)
    166     case \"gebco\" | \"gebcosi\":
    167         name = \"earth_gebco\"
--> 168 grid = _load_remote_dataset(
    169     name=name,
    170     prefix=prefix,
    171     resolution=resolution,
    172     region=region,
    173     registration=registration,
    174 )
    175 return grid

File d:\\Program Files\\Anaconda\\envs\\pygmt\\Lib\\site-packages\\pygmt\\helpers\\decorators.py:773, in kwargs_to_strings.<locals>.converter.<locals>.new_module(*args, **kwargs)
    770             bound.arguments[\"kwargs\"][arg] = newvalue
    772 # Execute the original function and return its output
--> 773 return module_func(*bound.args, **bound.kwargs)

File d:\\Program Files\\Anaconda\\envs\\pygmt\\Lib\\site-packages\\pygmt\\datasets\\load_remote_dataset.py:421, in _load_remote_dataset(name, prefix, resolution, region, registration)
    418         grid = lib.virtualfile_to_raster(outgrid=None, vfname=voutgrd)
    420 # Full path to the grid if not tiled grids.
--> 421 source = which(fname, download=\"a\") if not resinfo.tiled else None
    422 # Manually add source to xarray.DataArray encoding to make the GMT accessors work.
    423 if source:

File d:\\Program Files\\Anaconda\\envs\\pygmt\\Lib\\site-packages\\pygmt\\helpers\\decorators.py:609, in use_alias.<locals>.alias_decorator.<locals>.new_module(*args, **kwargs)
    603     msg = (
    604         \"Parameters 'Y' and 'yshift' are no longer supported since v0.12.0. \"
    605         \"Use Figure.shift_origin(yshift=...) instead.\"
    606     )
    607     raise GMTInvalidInput(msg)
--> 609 return module_func(*args, **kwargs)

File d:\\Program Files\\Anaconda\\envs\\pygmt\\Lib\\site-packages\\pygmt\\src\\which.py:66, in which(fname, **kwargs)
     61     with lib.virtualfile_out(kind=\"dataset\") as vouttbl:
     62         lib.call_module(
     63             module=\"which\",
     64             args=build_arg_list(kwargs, infile=fname, outfile=vouttbl),
     65         )
---> 66         paths = lib.virtualfile_to_dataset(vfname=vouttbl, output_type=\"strings\")
     68 match paths.size:
     69     case 0:

File d:\\Program Files\\Anaconda\\envs\\pygmt\\Lib\\site-packages\\pygmt\\clib\\session.py:1950, in Session.virtualfile_to_dataset(self, vfname, output_type, header, column_names, dtype, index_col)
   1947 result = self.read_virtualfile(vfname, kind=\"dataset\").contents
   1949 if output_type == \"strings\":  # strings output
-> 1950     return result.to_strings()
   1952 result = result.to_dataframe(
   1953     header=header, column_names=column_names, dtype=dtype, index_col=index_col
   1954 )
   1955 if output_type == \"numpy\":  # numpy.ndarray output

File d:\\Program Files\\Anaconda\\envs\\pygmt\\Lib\\site-packages\\pygmt\\datatypes\\dataset.py:171, in _GMT_DATASET.to_strings(self)
    169     warnings.warn(msg, category=RuntimeWarning, stacklevel=1)
    170     textvector = [item if item is not None else b\"\" for item in textvector]
--> 171 return np.char.decode(textvector) if textvector else np.array([], dtype=str)

File d:\\Program Files\\Anaconda\\envs\\pygmt\\Lib\\site-packages\
umpy\\core\\defchararray.py:615, in decode(a, encoding, errors)
    572 @array_function_dispatch(_code_dispatcher)
    573 def decode(a, encoding=None, errors=None):
    574     r\"\"\"
    575     Calls ``bytes.decode`` element-wise.
    576 
   (...)
    612 
    613     \"\"\"
    614     return _to_bytes_or_str_array(
--> 615         _vec_string(a, object_, 'decode', _clean_args(encoding, errors)))

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc5 in position 9: invalid continuation byte"
@PPaircas PPaircas added the bug Something isn't working label May 29, 2024
Copy link

welcome bot commented May 29, 2024

👋 Thanks for opening your first issue here! Please make sure you filled out the template with as much detail as possible. You might also want to take a look at our contributing guidelines and code of conduct.

@seisman
Copy link
Member

seisman commented May 29, 2024

What's the output if you run the GMT command gmt which -Ga @earth_relief_01d_g in terminal?

@seisman
Copy link
Member

seisman commented May 29, 2024

Also please post the output of the following script:

import pygmt
pygmt.which("@earth_relief_01d_g", download="a", verbose="d")

@PPaircas
Copy link
Author

What's the output if you run the GMT command gmt which -Ga @earth_relief_01d_g in terminal?

gmtwhich [ERROR]: No files specified

@PPaircas
Copy link
Author

Also please post the output of the following script:

import pygmt
pygmt.which("@earth_relief_01d_g", download="a", verbose="d")

snipaste_20240529_180604
snipaste_20240529_180626

@seisman
Copy link
Member

seisman commented May 29, 2024

What's the output if you run the GMT command gmt which -Ga @earth_relief_01d_g in terminal?

gmtwhich [ERROR]: No files specified

This doesn't make sense. What about the following command?

gmt which -Ga @earth_relief_01d_g -Vd

@PPaircas
Copy link
Author

What's the output if you run the GMT command gmt which -Ga @earth_relief_01d_g in terminal?

gmtwhich [ERROR]: No files specified

This doesn't make sense. What about the following command?

gmt which -Ga @earth_relief_01d_g -Vd

image

@seisman
Copy link
Member

seisman commented May 29, 2024

I see the issue. Your Windows account name contains Chinese characters, but GMT lacks support for paths with non-ASCII characters.

@seisman
Copy link
Member

seisman commented May 29, 2024

Actually GMT works well with non-ASCII paths on macOS, but on Windows, I'm unsure what's happening.

@PPaircas
Copy link
Author

Actually GMT works well with non-ASCII paths on macOS, but on Windows, I'm unsure what's happening.

Thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants