解决在linux移动anaconda到其他文件夹,conda: command not found的问题

解决linux 移动anaconda到其他文件夹,conda: command not found的问题

由于服务器的/home文件夹空间不够,需要把文件(/home/hu/miniconda3)移动到其他文件夹(/pub/data/hu/miniconda3)下,但移动之后的虚拟环境需要重新配置。

移动文件:

  1. mv /home/hu/miniconda3 /pub/data/hu/miniconda3
  2. In -s moved_directory original_directory(即ln -s /pub/data/hu/miniconda3 /home/hu/miniconda3)

现在输入“conda activate <虚拟环境名>”会遇到conda: command not found的问题,需要重新设置环境变量。

vim提示:vim中进行编写的快捷键是i,写完以后esc键退出编辑模式,然后shift键加冒号键(: )。 输入(wq) 然后enter键 。wq是保存加退出,q退出,q! 强制退出。

配置环境:

  • 在命令行输入vim ~/.bashrc
  • 插入export PATH=“/pub/data/hu/miniconda3/bin:$PATH”(这里用相对路径也可)
  • source ~/.bashrc使环境生效

输入“conda activate <虚拟环境名>”还是会遇到conda: command not found的问题.
继续配置环境。

vim编辑,修改以下文件的首行,改成现在的路径。例如,这是我 ./bin/conda的首行:#!/home/hu/miniconda3/bin/python 要改成 #!/pub/data/hu/miniconda3/bin/python

  • ./bin/conda
  • ./bin/activate
  • ./bin/deactivate
  • ./bin/pip

此时输入“conda activate <虚拟环境名>”,成功。

使用pip出现/bin/python: bad interpreter: No such file or directory:

按照下面可以解决:

which pip
/pub/data/hu/miniconda3/envs/clip/bin/pip

which python
/pub/data/hu/miniconda3/envs/clip/bin/python

vim /pub/data/hu/miniconda3/envs/clip/bin/pip

把#!后面的改成python的路径就好了

参考:anaconda 配置文件被移动到另一路径下,conda无法使用解决办法
https://blog.csdn.net/ganxiwu9686/article/details/98736127

根据cuda版本下载pytorch

https://pytorch.org/
https://www.zhihu.com/question/309583980
pytorch下载网址:
https://download.pytorch.org/whl/torch_stable.html

安装miniconda3

https://www.cnblogs.com/jessepeng/p/11685170.html

  • 18
    点赞
  • 35
    收藏
    觉得还不错? 一键收藏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值