ncap2:加载共享库时出错:libnetcdf.so.7:无法打开共享对象文件:没有这样的文件或目录

ncap2: error while loading shared libraries: libnetcdf.so.7: cannot open shared object file: No such file or directory

我尝试在远程服务器 (RHEL 7.8) 中安装 nco,但我不是 root,这意味着我无法在终端中使用 sudo 或 yum。然后我按照 nco 主页上的说明进行操作(http://nco.sourceforge.net/src/) in which it is said pre-built way is recommended. So I used conda method. But when I used conda install -c conda-forge nco, the speed is too low. And finally I was told solving the environment is not successful. After that I searched the nco in conda, in https://anaconda.org/conda-forge/nco 我被告知 conda install -c conda-forge/label/broken nco 可以。是的,安装完成。但是当我想使用命令 ncap2 时,有人告诉我

ncap2: error while loading shared libraries: libnetcdf.so.7: cannot open shared object file: No such file or directory

我检查了我的 LD_LIBRARY_PATH,但我找不到 link 朝向 libnetcdf.so.7。我使用 find 命令来查找 libnetcdf.so.7 的位置,但如您所知,我在服务器上操作,因此大多数访问都被拒绝。这是我的 ~/.bashrc:

export PATH="/home/xushan/anaconda3/bin:$PATH"
export PATH="$PATH:/home/xushan/openmpi/bin"
#export PATH= "$HOME/openmpi/bin:$PATH"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/xushan/openmpi/lib"
export VER_MPI="NOMPI"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/xushan/SURFEX_v8_1_public/open_SURFEX_V8_1/src/LIB"
#export VER_USER="FORC"
export PATH="/home/xushan/anaconda3/bin/ncdump:$PATH"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/xushan/anaconda3/lib"

有一件事很奇怪,当我从ls/usr/local/lib时,什么都没有.... 那么有没有办法帮我完成安装呢?我尝试了 http://nco.sourceforge.net/src/ 中建议的以下命令:

wget https://github.com/nco/nco/archive/4.9.4.tar.gz
tar xvzf 4.9.4.tar.gz
cd nco-4.9.4
./configure --prefix=/usr/local
make
sudo make install
export PATH=/usr/local/bin\:${PATH}
export LD_LIBRARY_PATH=/usr/local/lib\:${LD_LIBRARY_PATH}

但当我 运行 ./configure --prefix=/usr/local 时,有人告诉我

checking for /opt/local/include/netcdf.h... no
checking for /opt/local/lib/libnetcdf.a... no
checking netcdf.h usability... no
checking netcdf.h presence... no
checking for netcdf.h... no
configure: error: in `/home/xushan/nco-4.6.3':
configure: error: cannot find netCDF header
See `config.log' for more details

所以有没有人可以帮助我?多谢! (问题是我找不到 libnetcdf.so.7 在哪里......我是一个在远程服务器上编译东西的初学者......特别是普通用户禁止苏打水和百胜...... )

您可以为 nco 创建一个新的 conda 环境。它的依赖项可能与您当前环境中的某些程序冲突。

conda create -n myenv -c conda-forge python=3 nco
conda activate myenv
ncap2

更新 20200914:为了回应下面的后续评论,请理解 Conda 只是 NCO 的一个很好的安装程序,并确保您在 一个地方 拥有所有依赖项和库.只要 Conda bin 和 lib 目录在您的路径中排在第一位,Conda-installed NCO 就可以正常工作,无论是否在 Bash 脚本中。