Miniconda3教程

Miniconda3

1.安装

  1. Miniconda3官网获取链接,在下载目录执行:
powershell 复制代码
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh

没有weget,先安装

powershell 复制代码
yum -y install wget
  1. 在安装目录执行命令,开始安装
powershell 复制代码
bash Miniconda3-latest-Linux-x86_64.sh
  1. 选择安装路径
    选择安装目录,如果无需更改直接回车Enter,如需更改要输入绝对路径:

Anaconda3 will now be installed into this location:

/home/work/anaconda3

-- Press ENTER to confirm the location

-- Press CTRL-C to abort the installation

-- Or specify a different location below

  1. 问是否需要进行conda的初始化,建议输入no。若选择yes,是在/root/.bashrc目录中自动添加环境变量,会使得开机自动启动base环境。
  2. 最后安装成功出现以下内容
powershell 复制代码
To activate conda's base environment in your current shell session:
eval "$(/miniconda3/bin/conda shell.YOUR_SHELL_NAME hook)" 
To install conda's shell functions for easier access, first activate, then:
conda init
If you'd prefer that conda's base environment not be activated on startup, 
   set the auto_activate_base parameter to false: 
conda config --set auto_activate_base false
Thank you for installing Miniconda3!

要在当前shell会话中激活conda的基本环境:eval "$(/miniconda3/bin/conda shell。"YOUR_SHELL_NAME钩);如果您不希望在启动时激活conda的基本环境,请将auto_activate_base参数设置为false: conda config------set auto_activate_base false感谢您安装Miniconda3!

2.常用命令

1.激活|退出

source ./miniconda3/bin/activate env_name 激活指定环境

conda deactivate 退出miniconda

2.自定义快捷键

若想平时不在conda环境,则需要将.bashrc文件中的conda设置内容注释 。 平时在~/miniconda3/bin/下执行 source activate就可使用conda了。 更便捷的方法是在~/.bashrc 下添加 :

alias condaac='source ~/miniconda3/bin/activate'

alias condadac='conda deactivate'

3.添加镜像

powershell 复制代码
#添加镜像(清华源)
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes 
#查看
conda config --get channels
or
cat ~/.condarc

4.创建python虚拟环境

默认创建到miniconda安装目录下的envs里

powershell 复制代码
conda create -n py38 python=3.8     # -n是name的缩写,python不指定版本就默认最新版

5.查看已经安装的虚拟环境列表

powershell 复制代码
conda env list

6.删除虚拟环境

powershell 复制代码
conda env remove -n Test1

7.安装库

使用conda安装指定版本的库:使用conda install命令安装指定版本的库。例如,要安装Python 3.6版本的numpy库,可以使用以下命令:

powershell 复制代码
conda install numpy=1.18.5 python=3.6
conda install numpy python=3.8

这将从Conda仓库中下载并安装指定版本的numpy库及其所有依赖项。请注意,您需要指定要安装的库的名称和版本号,并且如果要安装特定版本的库,则需要指定要使用的Python版本。

相关推荐
databook9 小时前
Manim实现脉冲闪烁特效
后端·python·动效
程序设计实验室10 小时前
2025年了,在 Django 之外,Python Web 框架还能怎么选?
python
倔强青铜三11 小时前
苦练Python第46天:文件写入与上下文管理器
人工智能·python·面试
用户25191624271115 小时前
Python之语言特点
python
刘立军15 小时前
使用pyHugeGraph查询HugeGraph图数据
python·graphql
数据智能老司机18 小时前
精通 Python 设计模式——创建型设计模式
python·设计模式·架构
数据智能老司机19 小时前
精通 Python 设计模式——SOLID 原则
python·设计模式·架构
c8i21 小时前
django中的FBV 和 CBV
python·django
c8i21 小时前
python中的闭包和装饰器
python
这里有鱼汤1 天前
小白必看:QMT里的miniQMT入门教程
后端·python