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

相关推荐
花海如潮淹8 分钟前
硬件产品研发管理工具实战指南
前端·python
张彦峰ZYF17 分钟前
快速掌握Python编程基础
python
Json____30 分钟前
使用python的 FastApi框架开发图书管理系统-前后端分离项目分享
开发语言·python·fastapi·图书管理系统·图书·项目练习
安思派Anspire36 分钟前
LangGraph + MCP + Ollama:构建强大代理 AI 的关键(二)
人工智能·后端·python
站大爷IP40 分钟前
Python文件与目录比较全攻略:从基础操作到性能优化
python
ahead~2 小时前
【大模型入门】访问GPT_API实战案例
人工智能·python·gpt·大语言模型llm
大模型真好玩3 小时前
准确率飙升!GraphRAG如何利用知识图谱提升RAG答案质量(额外篇)——大规模文本数据下GraphRAG实战
人工智能·python·mcp
19893 小时前
【零基础学AI】第30讲:生成对抗网络(GAN)实战 - 手写数字生成
人工智能·python·深度学习·神经网络·机器学习·生成对抗网络·近邻算法
applebomb3 小时前
没合适的组合wheel包,就自行编译flash_attn吧
python·ubuntu·attention·flash
Chasing__Dreams3 小时前
python--杂识--18.1--pandas数据插入sqlite并进行查询
python·sqlite·pandas