简体   繁体   English

使用 python 3.4 在 windows 中安装 NETCDF4

[英]Installing NETCDF4 in windows using python 3.4

I have downloaded NETCDF4 module from https://pypi.python.org/pypi/netCDF4 eg netCDF4-1.3.1-cp34-cp34m-win_amd64.whl我已经从https://pypi.python.org/pypi/netCDF4下载了 NETCDF4 模块,例如netCDF4-1.3.1-cp34-cp34m-win_amd64.whl

I have installed it using pip install netCDF4-1.3.1-cp34-cp34m-win_amd64.whl我已经使用 pip install netCDF4-1.3.1-cp34-cp34m-win_amd64.whl安装了它

through command prompt in spyder.通过 spyder 中的命令提示符。 It has successfully installed.它已成功安装。 But when I am trying to import, it is giving an error:但是当我尝试导入时,它给出了一个错误:

import netCDF4 as nc4 Traceback (most recent call last):将 netCDF4 导入为 nc4 回溯(最近一次调用最后一次):

File "", line 1, in import netCDF4 as nc4文件“”,第 1 行,将 netCDF4 导入为 nc4

File "C:\\python3\\WinPython-64bit-3.4.4.5Qt5\\python-3.4.4.amd64\\lib\\site-packages\\netCDF4__init__.py", line 3, in from ._netCDF4 import *文件“C:\\python3\\WinPython-64bit-3.4.4.5Qt5\\python-3.4.4.amd64\\lib\\site-packages\\netCDF4__init__.py”,第 3 行,来自 ._netCDF4 导入 *

File "netCDF4_netCDF4.pyx", line 2988, in init netCDF4._netCDF4文件“netCDF4_netCDF4.pyx”,第 2988 行,在 init netCDF4._netCDF4 中

AttributeError: type object 'netCDF4._netCDF4.Dimension' has no attribute ' reduce_cython ' AttributeError:类型对象“netCDF4._netCDF4.Dimension”没有属性“ reduce_cython

How can I fix it?我该如何解决? Suggestions would be appreciated.建议将不胜感激。

I have solved the problem.我已经解决了这个问题。 However, it's better to avoid problems, use python 3.6.但是,最好避免出现问题,使用python 3.6。 It has no errors with netCDF4 and it comes with netCDF4. netCDF4 没有错误,它带有 netCDF4。

I had the same issue.我有同样的问题。 I am using python 3.7.8 with Anaconda to manage my packages and the primary channel is conda-forge.我使用 python 3.7.8 和 Anaconda 来管理我的包,主要渠道是 conda-forge。

I ha to update the cython package:我必须更新 cython 包:

The following packages will be downloaded:将下载以下软件包:

package                    |            build
---------------------------|-----------------
cython-0.29.21             |   py37h8e8dfb5_1         1.9 MB  conda-forge
------------------------------------------------------------
                                       Total:         1.9 MB    

The following packages will be UPDATED:以下软件包将被更新:

cython 0.29.21-py37h1834ac0_0 --> 0.29.21-py37h8e8dfb5_1 cython 0.29.21-py37h1834ac0_0 --> 0.29.21-py37h8e8dfb5_1

This update fixed my issue.此更新解决了我的问题。

Regards问候

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM