### 下载安装conda
下载地址:https://docs.conda.io/en/latest/
笔者下载的是`Miniconda3-latest-Linux-x86_64.sh`
安装:
```shell
bash Miniconda3-latest-Linux-x86_64.sh -b -p /home/software/miniconda3
# -p 可指定安装目录
# 安装后添加conde到 环境变量PATH中
export PATH=/home/software/miniconda3/bin/$PATH
# 执行初始化
conda init
```
### 创建环境报错
错误信息:
```shell
[root@localhost software]# conda create -n langchain python=3.9
Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate is not yet valid (_ssl.c:1032)'))': /pkgs/main/terms.json
```
错误原因:系统时间不正确
修改并同步时间:
```shell
# 停止 chronyd
sudo systemctl stop chronyd
# 手动设置一个可靠的时间源(可选)
sudo timedatectl set-ntp true
# 编辑 chrony 配置,使用国内源(加快同步)
sudo tee /etc/chrony.conf <<EOF
server ntp.aliyun.com iburst
server ntp1.aliyun.com iburst
server ntp2.aliyun.com iburst
driftfile /var/lib/chrony/drift
makestep 1.0 3
rtcsync
keyfile /etc/chrony.keys
leapsectz right/UTC
logdir /var/log/chrony
EOF
# 重启 chronyd
sudo systemctl restart chronyd
# 强制立即同步
sudo chronyc makestep
# 等待几秒后检查
chronyc tracking
date
# 更新 ca-certificates 包
sudo dnf update -y ca-certificates
# 重建证书信任链
sudo update-ca-trust force-enable
sudo update-ca-trust extract
# 验证证书路径(Python 通常使用此路径)
ls -l /etc/ssl/certs/ca-bundle.crt
```
### 条款信息未接受
错误信息:
```shell
[root@localhost software]# conda create -n langchain python=3.9 -y
CondaToSNonInteractiveError: Terms of Service have not been accepted for the following channels. Please accept or remove them before proceeding:
- https://repo.anaconda.com/pkgs/main
- https://repo.anaconda.com/pkgs/r
To accept these channels' Terms of Service, run the following commands:
conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main
conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r
For information on safely removing channels from your conda configuration,
please see the official documentation:
https://www.anaconda.com/docs/tools/working-with-conda/channels
```
错误原因: Anaconda 新增的“服务条款(Terms of Service, ToS)”需要强制接受
解决办法:接受条款
```shell
[root@localhost software]# conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/main
accepted Terms of Service for https://repo.anaconda.com/pkgs/main
[root@localhost software]# conda tos accept --override-channels --channel https://repo.anaconda.com/pkgs/r
accepted Terms of Service for https://repo.anaconda.com/pkgs/r
```
### 重新创建并激活环境
```shell
[root@localhost software]# conda init
[root@localhost software]# source ~/.bashrc
(base) [root@localhost software]# conda activate langchain
(langchain) [root@localhost software]#
Conda环境初始化遇到的问题记录