我是Python的新手,并尝试使用Xarray运行Metpy Tutorial,然后才可以,但是在我将Xarray更新为新版本之后,它显示了一个错误
我试图在Anaconda提示中创建另一个环境,并安装每个模块(包括Xarray((已经包括Xarray(
import metpy
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-4fe739b01247> in <module>
----> 1 import metpy
C:ProgramDataAnaconda3envscobaxarraylibsite-packagesmetpy__init__.py in <module>
13
14 from ._version import get_versions # noqa: E402
---> 15 from .xarray import * # noqa: F401, F403
16 __version__ = get_versions()['version']
17 del get_versions
C:ProgramDataAnaconda3envscobaxarraylibsite-packagesmetpyxarray.py in <module>
11
12 import xarray as xr
---> 13 from xarray.core.accessors import DatetimeAccessor
14 from xarray.core.indexing import expanded_indexer
15 from xarray.core.utils import either_dict_or_kwargs, is_dict_like
ModuleNotFoundError: No module named 'xarray.core.accessors'
This is the xarray installed versions outside my environment
INSTALLED VERSIONS
------------------
commit: None
python: 3.7.3 | packaged by conda-forge | (default, Mar 27 2019, 23:18:50) [MSC v.1900 64 bit (AMD64)]
python-bits: 64
OS: Windows
OS-release: 8.1
machine: AMD64
processor: Intel64 Family 6 Model 69 Stepping 1, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None
libhdf5: 1.10.4
libnetcdf: 4.6.2
xarray: 0.12.2
pandas: 0.24.2
numpy: 1.16.3
scipy: 1.2.1
netCDF4: 1.5.1.2
pydap: None
h5netcdf: None
h5py: 2.9.0
Nio: None
zarr: None
cftime: 1.0.3.4
nc_time_axis: 1.1.0
PseudonetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: 1.2.1
dask: 1.2.2
distributed: 1.28.1
matplotlib: 3.1.0
cartopy: 0.17.0
seaborn: 0.9.0
numbagg: None
setuptools: 41.0.1
pip: 19.1.1
conda: 4.7.5
pytest: 4.5.0
IPython: 7.5.0
sphinx: 2.0.1
This is the installed version of xarray inside my environment
INSTALLED VERSIONS
------------------
commit: None
python: 3.7.3 | packaged by conda-forge | (default, Jul 1 2019, 22:01:29) [MSC v.1900 64 bit (AMD64)]
python-bits: 64
OS: Windows
OS-release: 8.1
machine: AMD64
processor: Intel64 Family 6 Model 69 Stepping 1, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None
libhdf5: None
libnetcdf: None
xarray: 0.12.2
pandas: 0.24.2
numpy: 1.16.4
scipy: 1.2.1
netCDF4: None
pydap: None
h5netcdf: None
h5py: None
Nio: None
zarr: None
cftime: None
nc_time_axis: None
PseudonetCDF: None
rasterio: None
cfgrib: None
iris: None
bottleneck: None
dask: None
distributed: None
matplotlib: 3.1.1
cartopy: 0.17.0
seaborn: None
numbagg: None
setuptools: 41.0.1
pip: 19.1.1
conda: None
pytest: None
IPython: 7.6.1
sphinx: None
我想从Metpy教程中获得确切的结果,但是导入METPY模块时找不到模块,而该错误失败了教程,谢谢您的帮助
此问题是由于Xarray的更新为0.12.2。昨天刚刚发布了新的Metpy发布,因此这些问题已经解决。如果您只是升级了Metpy,那么一切都应该再次起作用:pip install --upgrade metpy
转到C:ProgramDataAnaconda3envscobaxarraylibsite-packagesmetpyxarray.py
查找行from xarray.core.accessors import DatetimeAccessor
将其更改为from xarray.core.accessor_dt import DatetimeAccessor
我必须在我的 .bashrc
文件中放置 anaconda3
,然后重新安装2020版的 anaconda3
,然后在 .bashrc
中进行初始化。
然后我做了...
conda update --all
conda update spyder
...然后我再次做了这两个以确保一切都安装了。
然后...
conda install -c conda-forge metpy
它安装了所有内容的好版本(包括xarray
(,现在按照广告宣传的是梅特皮画廊工作中的示例!