当前位置: 首页 > news >正文

CentOS7安装Miniconda

CentOS7安装Miniconda

1. 物料包

  • https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda
操作系统和芯片架构 文件
MacOS Intel Chip Miniconda3-latest-MacOSX-x86_64.sh
MacOS Apple Silicon Miniconda3-latest-MacOSX-arm64.sh
Linux x86_64 Miniconda3-latest-Linux-x86_64.sh
Linux aarch64 Miniconda3-latest-Linux-aarch64.sh
Windows x86_64 Miniconda3-latest-Windows-x86_64.exe

类似产品:

  • https://github.com/conda-forge/miniforge

2. 安装

[yangyunhe@sdp Downloads]$ sh Miniconda3-latest-Linux-x86_64.shWelcome to Miniconda3 py312_25.1.1-2In order to continue the installation process, please review the license
agreement.
Please, press ENTER to continue # 按下回车,浏览用户协议,一直按回车
>>> 
ANACONDA TERMS OF SERVICE
...
1. ACCESS & USE
...
2. USERS & LICENSING
...
3. ANACONDA OFFERINGS
...
4. OPEN SOURCE, CONTENT & APPLICATIONS
...
5. CUSTOMER CONTENT, APPLICATIONS & RESPONSIBILITIES
...
6. YOUR DATA, PRIVACY & SECURITY
...
7. SUPPORT
...
8. OWNERSHIP & INTELLECTUAL PROPERTY
...
9. CONFIDENTIAL INFORMATION
...
10. INDEMNIFICATION
...
11. LIMITATION OF LIABILITY
...
12. FEES & PAYMENT
...
13. TERM, TERMINATION & SUSPENSION
...
14. RECORDS, USER COUNT
...
15. GENERAL PROVISIONS
...
16. DEFINITIONS
...
Do you accept the license terms? [yes|no] # 是否同意协议,输入 yes
>>> Please answer 'yes' or 'no':'
>>> yesMiniconda3 will now be installed into this location:
/home/yangyunhe/miniconda3- Press ENTER to confirm the location # 回车确认默认的路径:/home/yangyunhe/miniconda3- Press CTRL-C to abort the installation # CTRL-C 退出安装- Or specify a different location below # 输入安装路径[/home/yangyunhe/miniconda3] >>> # 默认安装的用户 home 目录下,敲回车确认,这里可以手动输入一个其他路径
PREFIX=/home/yangyunhe/miniconda3
Unpacking payload ...Installing base environment... # 安装基础环境
...... installation finished.
Do you wish to update your shell profile to automatically initialize conda? # 是否初始化 conda,输入 yes,否则 conda 无法正常使用
This will activate conda on startup and change the command prompt when activated. # 初始化之后,系统开机后就会激活 conda 并且会改变命令提示符
If you'd prefer that conda's base environment not be activated on startup, # 如果不需要在系统启动之后激活 base 环境,那么在 conda 激活后执行以下命令run the following command when conda is activated:conda config --set auto_activate_base falseYou can undo this by running `conda init --reverse $SHELL`? [yes|no] # 你可以通过执行此命令来退回 conda 初始化操作
[no] >>> yes # 输入 yes
...
Thank you for installing Miniconda3![yangyunhe@sdp Downloads]$# 再次连接终端,命令提示符会改变,base 代表目前的 python 环境是 base
(base) [yangyunhe@sdp ~]$

3. 虚拟环境操作

miniconda 是为当前用户安装的,conda 初始化之后,修改了用户的 .bashrc 文件

if [ $? -eq 0 ]; theneval "$__conda_setup"
elseif [ -f "/home/yangyunhe/miniconda3/etc/profile.d/conda.sh" ]; then. "/home/yangyunhe/miniconda3/etc/profile.d/conda.sh"elseexport PATH="/home/yangyunhe/miniconda3/bin:$PATH"fi
fi
unset __conda_setup
# 查看 python 版本
(base) [yangyunhe@sdp ~]$ python -V
Python 3.12.9# 创建虚拟环境
(base) [yangyunhe@sdp ~]$ conda create -n testenv python=3.11
# 激活虚拟环境
(base) [yangyunhe@sdp ~]$ conda activate testenv
(testenv) [yangyunhe@sdp ~]$# 查看 python 版本
(testenv) [yangyunhe@sdp ~]$ python -V
Python 3.11.11# 查看现有的环境(* 代表目前生效的环境)
(testenv) [yangyunhe@sdp lib]$ conda env list# conda environments:
#
base                   /home/yangyunhe/miniconda3
testenv              * /home/yangyunhe/miniconda3/envs/testenv# 切换环境
(testenv) [yangyunhe@sdp ~]$ conda activate base
(base) [yangyunhe@sdp ~]$# 退出所有 miniconda 环境,返回系统的 python 版本
(base) [yangyunhe@sdp ~]$ conda deactivate
[yangyunhe@sdp ~]$
[yangyunhe@sdp ~]$ python -V
Python 2.7.5# 删除环境
[yangyunhe@sdp ~]$ conda env remove -n testenv# 设置不自动启用 base 环境
[yangyunhe@sdp ~]$ conda config --set auto_activate_base false

4. conda 设置清华大学源

https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/

~/.condarc 文件

channels:- defaults
default_channels:- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudpytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
anaconda_channels:- https://repo.anaconda.com/pkgs/main- https://repo.anaconda.com/pkgs/r
auto_activate_base: false
show_channel_urls: true

测试

# .condarc 有两个文件,/home/${user}/.condarc 和 /home/${user}/miniconda3/.condarc
# 都得修改,可以删除 /home/${user}/miniconda3/.condarc
(base) [yangyunhe@sdp ~]$ cp /home/yangyunhe/miniconda3/.condarc /home/yangyunhe/miniconda3/.condarc.bak
(base) [yangyunhe@sdp ~]$ rm -f /home/yangyunhe/miniconda3/.condarc
# 查看源
(base) [yangyunhe@sdp ~]$ conda config --show-sources
==> /home/yangyunhe/.condarc <==
channels:- defaults
custom_channels:conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloudpytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
default_channels:- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
show_channel_urls: True# 清除索引环境
(base) [yangyunhe@sdp ~]$ conda clean -i
Will remove 1 index cache(s).
Proceed ([y]/n)? y# 安装常用包测试
conda create -n myenv numpy# 删除测试环境
(base) [yangyunhe@sdp ~]$ conda env remove -n myenv

5 pip 设置清华大学源

修改 ~/.pip/pip.conf文件

[yangyunhe@sdp miniconda3]$ mkdir -p ~/.pip
[yangyunhe@sdp miniconda3]$ vim ~/.pip/pip.conf[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = pypi.tuna.tsinghua.edu.cn# 校验
[yangyunhe@sdp miniconda3]$ ~/miniconda3/bin/pip config list
global.index-url='https://pypi.tuna.tsinghua.edu.cn/simple'
install.trusted-host='pypi.tuna.tsinghua.edu.cn'
http://www.hn-smt.com/news/462/

相关文章:

  • P14322 「ALFR Round 11」E 空崎ヒナ 题解 (markdown)
  • [题解]P7074 [CSP-J 2020] 方格取数
  • 二分查找边界
  • P3232 [HNOI2013] 游走
  • 软件工程学习日志2025.10.27
  • 深入解析:TCP/IP 四层模型协作流程详解
  • Windows全版本激活教程(仅供测试)
  • 10月27日
  • javascript构造对象数组向服务器端传输
  • 10.25 CSP-S 模拟赛
  • 鲜花10/27
  • 读《程序员的修炼之路:从小工到专家》有感
  • 想让默认头像不再千篇一律,就顺手复刻了一下 GitHub 的思路
  • java(3)基础规范
  • 读书日记3
  • Tuack 生成 OI 比赛题目 PDF 笔记
  • 数据库三大范式、Union和Union all的区别
  • CSP-S2025 游记
  • 「LG3600-随机数生成器」题解
  • MathType7下载包安装教程2025最新下载+安装+汉化激活(附安装包,超详细)
  • 2025强网杯ezphp复现
  • 漏洞报告被拒绝的常见原因及避免方法
  • 【IEEE出版 | 重庆邮电大学主办 | 多届次、高层次】第六届人工智能与计算机工程国际学术会议(ICAICE 2025)
  • Docker容器里面部署的Jenkins的Java17升级到21版本(无需删除之前容器,内部在线升级) - 攻城狮
  • 报表知识
  • 渐进过程中大O与小o混用
  • 消息队列的有序性
  • 【LTDC】DMA2D —— 嵌入式系统的 GPU
  • unity管理器设计:Manager of Managers
  • iview table 排序 columns 里面写 sortable: custom 不要写 sortable: true 不然会进行二次内部排序序号等 字段。