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版本。

相关推荐
用户83562907805137 分钟前
Python 实现 PowerPoint 形状动画设置
后端·python
ponponon2 小时前
时代的眼泪,nameko 和 eventlet 停止维护后的项目自救,升级和替代之路
python
Flittly2 小时前
【从零手写 ClaudeCode:learn-claude-code 项目实战笔记】(5)Skills (技能加载)
python·agent
敏编程2 小时前
一天一个Python库:pyarrow - 大规模数据处理的利器
python
Flittly4 小时前
【从零手写 ClaudeCode:learn-claude-code 项目实战笔记】(4)Subagents (子智能体)
python·agent
明月_清风11 小时前
Python 装饰器前传:如果不懂“闭包”,你只是在复刻代码
后端·python
明月_清风11 小时前
打破“死亡环联”:深挖 Python 分代回收与垃圾回收(GC)机制
后端·python
ZhengEnCi1 天前
08c. 检索算法与策略-混合检索
后端·python·算法
明月_清风1 天前
Python 内存手术刀:sys.getrefcount 与引用计数的生死时速
后端·python
明月_清风1 天前
Python 消失的内存:为什么 list=[] 是新手最容易踩的“毒苹果”?
后端·python