如何在Ubuntu 16.04上安装Anaconda

在阅读这篇教程之前,请做好失败很多次的心理准备
毕竟每个人电脑不一样,这个并不像装QQ那样简单
教程不保证有效,仅供你和我遇到同样错误时的参考
感觉得完全弄懂~./bashrc这个文件还有环境变量的配置
建议读者自己去搜清楚会减少很多麻烦
首先,阅读这篇教程
https://cloud.tencent.com/developer/article/1349098
教程上面是18.04,我是16.04的开发环境
我是在腾讯云的Cloud Studio下安装的
遇到了一些问题并经过了辛苦的搜索
查阅了很多英文文档才解决的
现将解决过程记录如下:
激活安装
source ~/.bashrc
报错source: no such file or directory: /home/coding/.bashrc
然后直接尝试输入conda命令,会报错无法查找conda命令
于是乎查看这篇文章如何配置环境变量
https://blog.csdn.net/caomin1hao/article/details/78341568
但是使用gedit时报错无法查找gedit命令
解决方案:
sudo apt-get install gedit
后来再尝试使用gedit命令
还是无法找到~/.bashrc文件
解决方案:
先不管这个~/.bashrc文件
直接使用命令
export PATH=~/anaconda3/bin:$PATH
将conda添加到了环境变量
后来尝试安装虚拟环境
conda create --name my_env python=3.6.6
报错,具体错误参考https://github.com/conda/conda/issues/7267

% conda create --name my_env python=3.6.6
Solving environment: failed

NotWritableError: The current user does not have write permissions to a required path.
  path: /home/coding/.conda/pkgs/urls.txt
  uid: 1009
  gid: 1009

If you feel that permissions on this path are set incorrectly, you can manually
change them by executing

  $ sudo chown 1009:1009 /home/coding/.conda/pkgs/urls.txt

In general, it's not advisable to use 'sudo conda'.

没有权限的就按照提示分配权限
少了urls.txt文件就在那个目录下面创一个urls.txt文件
cd /home/coding/.conda/pkgs
touch urls.txt
再次尝试安装虚拟环境
还是报错

An unexpected error has occurred. Conda has prepared the above report.
If submitted, this report will be used by core maintainers to improve
future releases of conda.
Would you like conda to send this report to the core maintainers?
[y/N]: y
Upload successful.

Thank you for helping to improve conda.
Opt-in to always sending reports (and not see this message again)
by running

    $ conda config --set report_errors true

这时候终极解决方案就是
sudo rm ~/.bashrc
再次尝试安装虚拟环境
报错,没有权限的按照提示赋予权限即可
再次安装虚拟环境,成功
开始快乐的开发之旅

猜你喜欢

转载自blog.csdn.net/weixin_43851212/article/details/89790008