爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 6961|回复: 2

[其他] 如何在shell脚本中调用NCL(conda版本)[已解决]

[复制链接]

新浪微博达人勋

发表于 2022-6-29 18:13:42 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
本帖最后由 channam 于 2022-6-30 09:44 编辑



江湖救急呀

因为在linux上安装的ncl为anaconda版本的,我在linux里每次运行ncl,需要输入命令conda activate ncl_stable ,激活ncl环境。
运行完ncl脚本,再conda deactivate,退出ncl环境。

现在想在shell脚本里运行ncl脚本

但是在shell脚本里写 conda activate ncl_stable  和  conda deactivate,会报错,请问有没有解决的办法呀???

脚本:
#!/bin/bash
conda activate ncl_stable

......
ncl hynout_txt.ncl
conda deactivate


报错:
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run

    $ conda init <SHELL_NAME>

Currently supported shells are:
  - bash
  - fish
  - tcsh
  - xonsh
  - zsh
  - powershell

See 'conda init --help' for more information and options.

IMPORTANT: You may need to close and restart your shell after running 'conda init'.


autochem_out.sh: line 101: ncl: command not found

CommandNotFoundError: Your shell has not been properly configured to use 'conda deactivate'.
To initialize your shell, run

    $ conda init <SHELL_NAME>

Currently supported shells are:
  - bash
  - fish
  - tcsh
  - xonsh
  - zsh
  - powershell

See 'conda init --help' for more information and options.

IMPORTANT: You may need to close and restart your shell after running 'conda init'.

------------------------------------------------------------------------------------------------------------------
解决方法:在shell脚本里最上面添加 source ~/.bashrc 即可。

#!/bin/bashsource ~/.bashrc
conda activate ncl_stable

......
ncl hynout_txt.ncl
conda deactivate




密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2022-6-29 18:58:37 | 显示全部楼层
source /path/anaconda/bin/activate env_name
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

新浪微博达人勋

 楼主| 发表于 2022-6-30 09:45:02 | 显示全部楼层
名字真难取 发表于 2022-6-29 18:58
source /path/anaconda/bin/activate env_name

谢谢回复,看到你这个source,我就在shell脚本里添加source ~/.bashrc 就解决了。
密码修改失败请联系微信:mofangbao
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表