Ubuntu下Anaconda3安装完成后测试conda: command not found,找不到conda命令解决办法

文章目录


问题

Ubuntu下Anaconda3安装完成后测试conda -V报错: command not found,$ source ~/.bashrc报错-sh: 1: source: not found

解决办法

$ echo 'export PATH="/home/users/zwc/anaconda3/bin:$PATH"' >> ~/.bashrc
$ source ~/.bashrc
报错
-sh: 1: source: not found

原因:sh 和 bash 是不同的 shell,sh中没有 source 命令。所以用 sh 或者 ./ 运行的时候,会提示这个错误。

测试:
运行 ls -l /bin/sh 后显示/bin/sh -> dash
这说明是用dash来进行解析的。

$ ls -l /bin/sh
lrwxrwxrwx 1 root root 4 6月  23 01:53 /bin/sh -> dash

解决方案:
命令行执行:dpkg-reconfigure dash(需要root权限)
在界面中选择no
再运行ls -l /bin/sh 后显示/bin/sh -> bash
这个操作需要root权限,实验室公用服务器上不太方便改,可以使用exec bash来从dash切换到bash,就能正常使用source了

$ exec bash
(base) zwc@ubuntu:~$ anaconda -V

anaconda Command line client (version 1.7.2)
(base) zwc@ubuntu:~$

显示安装成功

(base) zwc@ubuntu:~$ python
Python 3.8.8 (default, Apr 13 2021, 19:58:26)
[GCC 7.3.0] :: Anaconda, Inc. on linux

参考链接:ubuntu系统shell 中source: not found错误

  • 5
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值