Ubuntu下anaconda的安装和基本使用

1 安装

1.1 开始安装

bash Anaconda3-2018.12-Linux-x86_64.sh

显示以下协议,按回车直到末尾,别按太快,我按太快了,导致安装出错。

Welcome to Anaconda3 2018.12

In order to continue the installation process, please review the license

agreement.

Please, press ENTER to continue

>>>

...

Do you approve the license terms? [yes|no]

输入yes。

1.2 指定安装位置

Anaconda3 will now be installed into this location:

/home/sammy/anaconda3​

  - Press ENTER to confirm the location

  - Press CTRL-C to abort the installation

  - Or specify a different location below​

[/home/sammy/anaconda3] >>>

直接回车。

1.3 完成安装

installation finished.

Do you wish the installer to prepend the Anaconda3 install location

to PATH in your /home/sammy/.bashrc ? [yes|no]

[no] >>>

是否添加环境变量,yes。

Do you wish to proceed with the installation of Microsoft VSCode? [yes|no]
是否安装visual studio code,输入no。

1.4 激活

source ~/.bashrc

2 使用

$ conda --version /* 查看版本 */

$ conda create --name my_env python=3 /* 创建虚拟环境,my_env 是自定义的名字 */

$ conda activate my_env /* 激活虚拟环境 */

$ source activate my_env /* 切换虚拟环境 */

$ conda deactivate /* 停用虚拟环境 */

$ conda info --envs /* 查看所有虚拟环境 */

$ conda env remove -n my_env /* 删除虚拟环境 */

$ conda list /* 查看当前虚拟环境下的所有包 */

$ conda install numpy /* 安装包 */

$ anaconda-navigator /* 图形化界面 */

3 我犯的二逼错误

3.1 虚拟环境与包

3.1.1 问题的发生

在虚拟环境下使用conda install安装包以后,在jupyter中import不成功。

3.1.2 排除的过程 之 徒劳无功

打开虚拟环境的路径,确实有包存在,但就是不能import。

但是,bash下安装同样的包,则可以import。

那么可以推定,虚拟环境没有切换成功。

可是提示符明明是虚拟环境,而不是bash。

这个事折腾了一夜也没弄好。

3.1.3 排除过程 之 莫名其妙

第二天用图形界面把虚拟环境、bash下自己安装的包移除,用图形界面重新安装。

在虚拟环境下启动jupyter,提示不存在。原来虚拟环境还没安装jupyter。

用图形界面在虚拟环境下安装jupyter之后,启动成功,import成功。

3.1.4 遗留的疑问

既然问题出在虚拟环境没有安装jupyter,那么昨天晚上为什么可以在虚拟环境启动jupyter,并且提示符明明白白显示虚拟环境?

难道是我老眼昏花?还是熬夜把脑子熬坏了?

现在脑子确实不如从前,这种问题如果不写下来,很快就会忘。所以记在这里,有时间了再尝试复现。

你可能感兴趣的:(开发环境配置)