【python读取nc文件】报错:ValueError: unrecognized engine netcdf4 must be one of: [‘store‘]

简介: 【python读取nc文件】报错:ValueError: unrecognized engine netcdf4 must be one of: [‘store‘]

写在最前面

尝试2019华为杯E题,但是报错:

ValueError: unrecognized engine netcdf4 must be one of: [‘store’]

Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings…

最终解决

报错1:ValueError: found the following matches with the input file in xarray’s IO backends: [‘netcdf4’, ‘h5netcdf’]. But their dependencies may not be installed, see:

https://docs.xarray.dev/en/stable/user-guide/io.html

https://docs.xarray.dev/en/stable/getting-started-guide/installing.html

参考:https://blog.csdn.net/linxi4165/article/details/118470843

conda install xarray

注意:Python最好3.9以上

下载链接:

https://pypi.tuna.tsinghua.edu.cn/simple/netcdf4/

下载与系统对应的netCAD4,一定要注意32位还是64位,以及操作系统的类型。

找到python对应版本的

Ctrl+F进行网页搜索

该文件放到开始conda环境的cmd目录下

在pip>后输入

pip install -i https://pypi.tuna.tsinghua.edu.cn/simplenetCDF4-1.5.4-cp39-cp39-win_amd64.whl

加粗部分自行替代成自己下载版本的名字,也就是下载的WHL文件的全名之后等待安装即可。

报错二:ValueError: unrecognized engine netcdf4 must be one of: [‘store’] Output is truncated. View as a scrollable element or open in a text editor. Adjust cell output settings…

参考:https://blog.csdn.net/showpingzhang/article/details/83384780

代码修改为:

# -*- coding: utf-8 -*-
import netCDF4
from netCDF4 import Dataset
nc_obj=Dataset('e:\\P_CLDAS_RE01_EA16_PRE_HOUR_2015010101.nc')
#查看nc文件有些啥东东
print(nc_obj)
print('---------------------------------------')
#查看nc文件中的变量
print(nc_obj.variables.keys())
for i in nc_obj.variables.keys():
    print(i)
print('---------------------------------------')
#查看每个变量的信息
print(nc_obj.variables['LAT'])
print(nc_obj.variables['LON'])
print(nc_obj.variables['PRCP'])
print('---------------------------------------')
#查看每个变量的属性
print(nc_obj.variables['LAT'].ncattrs())
print(nc_obj.variables['LON'].ncattrs())
print(nc_obj.variables['PRCP'].ncattrs())
print(nc_obj.variables['LAT'].units)
print(nc_obj.variables['LON'].units)
print(nc_obj.variables['PRCP']._Fillvalue)
print('---------------------------------------')
#读取数据值
lat=(nc_obj.variables['LAT'][:])
lon=(nc_obj.variables['LON'][:])
prcp=(nc_obj.variables['PRCP'][:])
print(lat)
print(lon)
print('---------------******-------------------')
print(prcp)

目录
相关文章
|
13天前
|
安全 项目管理 Python
使用Python shutil库进行文件和目录操作
使用Python shutil库进行文件和目录操作
使用Python shutil库进行文件和目录操作
|
2天前
|
Java 数据安全/隐私保护 Python
Python案例分享:如何实现文件的解压缩
Python案例分享:如何实现文件的解压缩
19 8
|
2天前
|
存储 缓存 安全
Python案例分享:如何实现文件的上传下载
Python案例分享:如何实现文件的上传下载
22 6
|
13天前
|
Python
像导入Python模块一样导入ipynb文件
像导入Python模块一样导入ipynb文件
|
13天前
|
TensorFlow 算法框架/工具 C++
Python exe文件打包神器-Nuitka!
Python exe文件打包神器-Nuitka!
|
13天前
|
存储 安全 Python
Python中临时文件的妙用
Python中临时文件的妙用
|
14天前
|
数据可视化 Python
通过python建立一个web服务查看服务器上的文本、图片、视频等文件
通过python建立一个web服务查看服务器上的文本、图片、视频等文件
16 0
|
4月前
|
Ubuntu Python
【Python】报错ModuleNotFoundError: No module named ‘XXX‘
【Python】报错ModuleNotFoundError: No module named ‘XXX‘
|
2月前
|
Python
【Python】已解决:(from docx import Document导包报错)ModuleNotFoundError: No module named ‘exceptions’
【Python】已解决:(from docx import Document导包报错)ModuleNotFoundError: No module named ‘exceptions’
85 0
|
2月前
|
机器学习/深度学习 文字识别 开发者
【Python】已解决:(paddleocr导包报错)ModuleNotFoundError: No module named ‘paddle’
【Python】已解决:(paddleocr导包报错)ModuleNotFoundError: No module named ‘paddle’
127 0