安装conda

1. 软件下载

https://repo.anaconda.com/archive/index.html

复制代码
wget -c https://repo.anaconda.com/archive/Anaconda3-2025.06-1-Linux-x86_64.sh -P /tmp/package

2. 安装conda

在conda文件的目录下输入命令安装,一路回车,直到他要求输入yes

复制代码
bash Anaconda3-2025.06-1-Linux-x86_64.sh

配置环境

复制代码
vim /etc/profile
最后添加

#anaconda3
export PATH=/root/anaconda3/bin:$PATH

继续

vim ~/.bashrc
 
#anaconda3
export PATH=/root/anaconda3/bin:$PATH

刷新

复制代码
source /etc/profile
source ~/.bashrc

然后conda -V要是正常就安装成功了

复制代码
(base) [root@localhost package]# conda -V
conda 25.5.1

镜像源配置

conda配置

复制代码
vim ~/.condarc

添加如下内容

channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
show_channel_urls: true
 
ssl_verify: true
allow_conda_downgrades: true

pip配置

复制代码
mkdir ~/.pip
cd ~/.pip/
cat > ~/.pip/pip.conf <<EOF
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
timeout = 120
EOF

# 确保你在 'python' 环境中
conda activate python

# 安装适用于 Linux 64 位的 Conda 编译器包 
conda install gcc_linux-64 gxx_linux-64

#在当前激活的 python 环境中运行前面需要做准备工作

列出并定位问题文件

先看看是哪些文件在引用失效的源:

复制代码
cd /etc/yum.repos.d/
grep -l "mirrorlist.centos.org" *.repo

由于 CentOS 7 的 SCL(Software Collections)官方源已完全不可用,这些文件可以安全删除。

清理缓存并测试

复制代码
sudo yum clean all
sudo yum makecache

建好仓库后执行
sudo yum install -y glibc-devel libxcrypt-devel

验证
ls /usr/include/crypt.h

输出如下就成功了
(base) [root@localhost yum.repos.d]# ls -lh /usr/include/crypt.h
-rw-r--r--. 1 root root 2.3K 6月   4 2024 /usr/include/crypt.h

常用命令

复制代码
# 创建虚拟环境
conda create -n python python==3.10
 
# 激活环境
conda activate python
 
# 退出环境
conda deactivate
 
# 查看虚拟环境
conda info --envs
 
# 删除虚拟环境
conda remove -n python --all
 
 
# 删除所有的安装包及cache(索引缓存、锁定文件、未使用过的包和tar包)
conda clean -y --all
 
# 删除pip的缓存
rm -rf ~/.cache/pip 
相关推荐
Είναι η κοπέλα2 天前
Python 虚拟环境:venv、conda 与 Python 版本选择全解
开发语言·python·conda
夏天拐跑了西瓜4 天前
一文入门LangChain:从框架认知到构建你的第一个AI Agent
python·langchain·conda·agent
weixin_461769405 天前
机械臂SDK运行日志
conda·sdk
三点水-here6 天前
从 Miniconda 迁移到 Miniforge3 全记录:安装、配置、环境迁移与排错实录
python·conda
MI_farmer7 天前
Anaconda 安装在 D 盘但虚拟环境跑到 C 盘,以及 Conda PermissionError: WinError 5 的解决方法
c语言·开发语言·conda
伞伞悦读14 天前
【第39期】Python 第三方包安装详解:pip、conda、requirements、版本锁定和镜像源
python·conda·pip
梦想不只是梦与想16 天前
环境管理:Conda 与 venv
python·conda·uv
梦想不只是梦与想18 天前
环境管理系统:Conda(一)
python·conda·环境隔离
Blockbuater_drug19 天前
Protenix: conda 环境部署、零基础安装
conda·开源模型·字节跳动·v2·蛋白结构预测·protenix
AlfredZhao19 天前
执行新项目 python 脚本前,先用 conda 建一个独立环境
conda