下载Anaconda
1.下载(选择官网或者清华镜像,二选一
清华:清华大学开源软件镜像站 | Tsinghua Open Source Mirror
这里选择清华镜像,点击下载
2.安装
2-1:一直按着enter不松手,直至需要输入yes
2-2:想要安装
anaconda3
的位置,默认位置/home/用户名/anaconda3
回车即可,如果自定义位置直接输入安装位置即可。(这里直接回车
2-3: 安装完后提示是否需要初始化,输入yes:
初始化yes or no的区别:Linux安装anaconda3是否初始化的区别 - 腾讯云开发者社区
【输入yes,这里就结束了。输入no,还需要手动修改环境变量】
手动修改环境变量 将Anaconda3添加到用户环境变量,使用sudo gedit ~/.bashrc命令编辑~/.bashrc文件,添加内容:export PATH="/home/用户名/anaconda3/bin:$PATH"。使用source ~/.bashrc 命令让~/.bashrc文件生效。 注:上文修改的文件是/home/用户名/.bashrc,如果想要在root用户中同样使用anaconda3,需要修改/root/.bashrc文件,同样添加:export PATH="/home/用户名/anaconda3/bin:$PATH"。
3.检查是否安装成功
新建一个终端,输入conda env list
!!注意:
1.在'下载'的文件夹下bash。注意位置,且不是使用sudo bash
2.不要自己创建anaconda3文件夹,否则会出现ERROR: File or directory already exists
1.an unexpected error has occurred. conda has prepared the above report
解决:关闭代理
参考:关于conda无法升级,提示报错an unexpected error has occurred. conda has prepared the above report的解决办法 - 知乎
2.
june@june:~$ conda activate fcn
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
If your shell is Bash or a Bourne variant, enable conda for the current user with$ echo ". /home/june/anaconda3/etc/profile.d/conda.sh" >> ~/.bashrc
or, for all users, enable conda with
$ sudo ln -s /home/june/anaconda3/etc/profile.d/conda.sh /etc/profile.d/conda.sh
The options above will permanently enable the 'conda' command, but they do NOT
put conda's base (root) environment on PATH. To do so, run$ conda activate
in your terminal, or to put the base environment on PATH permanently, run
$ echo "conda activate" >> ~/.bashrc
Previous to conda 4.4, the recommended way to activate conda was to modify PATH in
your ~/.bashrc file. You should manually remove the line that looks likeexport PATH="/home/june/anaconda3/bin:$PATH"
^^^ The above line should NO LONGER be in your ~/.bashrc file! ^^^
解决:source activate fcn
3.命令
退出虚拟环境:
conda deactivate
删除虚拟环境:
conda remove -n env_name --all # 必须要加all
其他命令:
#创建虚拟环境
conda create -n your_env_name python=X.X(3.6、3.7等)
#激活虚拟环境
source activate your_env_name(虚拟环境名称) # 不用source也可以
#退出虚拟环境
source deactivate your_env_name(虚拟环境名称) # 不用source也可以
#删除虚拟环境
conda remove -n your_env_name(虚拟环境名称) --all
#查看安装了哪些包
conda list
#安装包
conda install package_name(包名)
conda install scrapy==1.3 # 安装指定版本的包
conda install -n 环境名 包名 # 在conda指定的某个环境中安装包
#查看当前存在哪些虚拟环境
conda env list
#或
conda info -e
#或
conda info --envs
#检查更新当前conda
conda update conda
#更新anaconda
conda update anaconda
#更新所有库
conda update --all
#更新python
conda update python
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
# 更新conda conda update -n base conda conda update -all # 修改频道 conda config --add channels conda-forge conda config --set channel_priority flexible # 安装成功!