简体   繁体   English

如何将netcdf4-python安装到ubuntu14.04?

[英]How can I install netcdf4-python to ubuntu14.04?

I would like to install netcdf4-python to my Ubuntu14.04. 我想将netcdf4-python安装到我的Ubuntu14.04。 The libhdf5-dev_1.8.11_5ubuntu7_amd64.deb and libnetcdf-4.1.3-7ubuntu2_amd64.deb are installed. 安装了libhdf5-dev_1.8.11_5ubuntu7_amd64.deb和libnetcdf-4.1.3-7ubuntu2_amd64.deb。 I downloaded netcdf4-1.1.8.tar.gz from https://pypi.python.org/pypi/netCDF4#downloads I tried configure it by 我从https://pypi.python.org/pypi/netCDF4#downloads下载了netcdf4-1.1.8.tar.gz我试过配置它

./configure --enable-netcdf-4 –with-hdf5=/usr/include/ --enable-share –prefix=/usr

but I got the following message: 但我收到以下消息:

bash: ./configure: No such file or directory

I do not know how I can install netcdf4-python. 我不知道如何安装netcdf4-python。 I would appreciated if someone helped me. 如果有人帮助我,我会很感激。

I would strongly recommend using the Anaconda Python distribution. 我强烈建议使用Anaconda Python发行版。 The full Anaconda distribution includes netcdf4 and the required libraries. 完整的Anaconda发行版包括netcdf4和所需的库。

The instructions for Ubuntu are here which are basically: 为Ubuntu的指令是在这里它们基本上是:

HDF5 HDF5

Download the current HDF5 source release. 下载当前的HDF5源版本。 Unpack, go into the directory and execute: 解压缩,进入目录并执行:

./configure --prefix=/usr/local --enable-shared --enable-hl
make 
sudo make install

To speed things up, compile on more than one processor using 为了加快速度,请使用多个处理器进行编译

make -j n 

where n is the number of processes to be launched. 其中n是要启动的进程数。

netCDF4 e Download the current netCDF4 source release. netCDF4 e下载当前的netCDF4源代码版本。 Unpack, go into the directory and execute: 解压缩,进入目录并执行:

LDFLAGS=-L/usr/local/lib CPPFLAGS=-I/usr/local/include ./configure --enable-netcdf-4 --enable-dap --enable-shared --prefix=/usr/local
make 
make install

Installing netcdf4-python When both HDF5 and netCDF4 are in /usr/local, make sure the linker will be able to find those libraries by executing 安装netcdf4-python当HDF5和netCDF4都在/ usr / local中时,请确保链接器能够通过执行来找到这些库

sudo ldconfig

then installing netcdf4-python is just a matter of doing 然后安装netcdf4-python只是一个问题

python setup.py install

Make sure you actually untar the files and cd to the correct directories. 确保你实际解开文件并cd到正确的目录。

您还可以使用netCDF4的替代包装器,如netcdf库(它自动从源代码编译hdf5和netCDF4库),使用:

pip install netcdf

The netCDF4 python module documentation can be found here . 可以在此处找到netCDF4 python模块文档。 Check out the "Install" section; 查看“安装”部分; it'll have what you're looking for. 它会有你想要的东西。 But, if you satisfy all of the pre-requisites you can simply do the following: 但是,如果您满足所有先决条件,您只需执行以下操作:

python setup.py build && python setup.py install

After much struggle with the installation and getting errors similar to the ones mentioned in this post, I ended up installing it as follows: 经过很多努力与安装和获得类似于这篇文章中提到的错误,我最终安装如下:

1) Installed HDF5 1)安装HDF5

./configure --prefix=/usr/local --enable-shared --enable-hl
make 
sudo make install

2) Installed netcdf4 2)安装netcdf4

 sudo pip install netcdf4

I guess the pip command would have installed the pre-requisite HDF5 as well even if I didn't do step (1). 我猜即使我没有执行步骤(1),pip命令也会安装必备的HDF5。 Btw, I have pip version 8.0.2 and python 2.7 顺便说一下,我有点版本8.0.2python 2.7

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

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