当前位置: 首页 > 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.fuzeviewer.com/news/462/

相关文章:

  • 第四篇:docker底层原理
  • 关于springboot+Servlet报错404的问题
  • Codechef Painting Tree 题解 [ 蓝 ] [ 树形 DP ] [ 概率期望 ] [ 分类讨论 ]
  • 【CI130x 离在线】如何运行 curl 脚本
  • 这才是真正的AI NAS!极空间私有云Z2Ultra评测
  • 新东方第三节课名言作文
  • 十月阅读_3
  • 中考_体育
  • 常见问题处理 --- phpstudy启动mysql失败
  • 20232308 2025-2026-1 《网络与系统攻防技术》实验三实验报告
  • 【密码学实战】openHiTLS PKCS12命令行程序: PKCS12文件生成与解析
  • 「CTSC2017-游戏」题解
  • vue3 vue3-form-element表单生成工具 输入框增加后缀
  • 20232402 2025-2026-1 《网络与系统攻防技术》实验三实验报告
  • 掘金2025年:数字化商业浪潮下,如何选对平台与伙伴?一站式多商户商城系统推荐榜发布,多商户商城代理招募/多商户项目合伙人加盟/一站式开店代理项目加盟
  • 为医疗器械行业搭建“数字桥梁”,破解协同效率与合规难题
  • PostgreSQL 服务版
  • 20232307 2025-2026-1 《网络与系统攻防技术》实验三实验报告
  • 2025年10月办公家具公司评价榜:基于真实数据的权威推荐清单
  • vue+antv/x6项目使用问题
  • 《程序员修炼之道:从小工到专家》前五分之一观后感
  • 坐标系与投影关系
  • 用gdb的动态视角看ret2text的实现
  • 1027随笔
  • ask_skill
  • SVN 主分支合并之通过主分支合并子分支执行流程
  • 现代c++编程体验2
  • 化繁为简:解密国标GB28181算法算力平台EasyGBS如何以兼容性与易用性赋能安防集成
  • 计算机毕业设计springboot音乐畅听系统 基于Spring Boot框架的智能音乐播放系统编写 Spring Boot驱动的音乐在线欣赏平台构建
  • vue2 封装组件使用 v-mode【el-radio,el-input】