You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

MacBook M1环境下Conda中Python SSL模块不可用致Pip安装失败

MacBook M1 Anaconda Python 3.8环境pip SSL模块不可用问题

问题现象

在MacBook M1上通过Anaconda创建Python 3.8环境后,使用pip安装任何库均触发SSL模块不可用错误,具体报错如下:

(llm) mdrahman@Mds-MacBook-Pro-3 ~ % python -m pip install --upgrade pip

WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Requirement already satisfied: pip in ./anaconda3/envs/llm/lib/python3.8/site-packages (23.0.1)
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pip/
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
(llm) mdrahman@Mds-MacBook-Pro-3 ~ % pip install pandas
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pandas/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pandas/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pandas/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pandas/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/pandas/
Could not fetch URL https://pypi.org/simple/pandas/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pandas/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
ERROR: Could not find a version that satisfies the requirement pandas (from versions: none)
ERROR: No matching distribution found for pandas

已执行排查操作

  • 检查环境内SSL相关文件存在:
(llm) mdrahman@Mds-MacBook-Pro-3 llm % ls
bin     conda-meta  include     lib     share       ssl
(llm) mdrahman@Mds-MacBook-Pro-3 llm % ls ./ssl 
cacert.pem      cert.pem        ct_log_list.cnf     ct_log_list.cnf.dist    misc            openssl.cnf     openssl.cnf.dist
  • 尝试通过conda安装openssl,提示已安装:
(llm) mdrahman@Mds-MacBook-Pro-3 llm % conda install -c anaconda openssl

Collecting package metadata (current_repodata.json): done
Solving environment: done

# All requested packages already installed.

解决方案

1. 重新创建适配M1架构的Python3.8环境

M1芯片为ARM架构,部分旧版本openssl与Python3.8的conda环境存在适配问题,重新创建环境时指定兼容的openssl版本:

conda create -n llm_new python=3.8 openssl=1.1.1k

创建完成后激活新环境,再尝试使用pip安装库。

2. 手动指定SSL证书路径

激活现有环境后,设置环境变量指向环境内的SSL证书:

export SSL_CERT_FILE=$CONDA_PREFIX/ssl/cacert.pem

若要永久生效,可将上述命令添加到环境的激活脚本中:

  1. 创建脚本目录:mkdir -p $CONDA_PREFIX/etc/conda/activate.d
  2. 编辑$CONDA_PREFIX/etc/conda/activate.d/env_vars.sh,写入上述export命令。

3. 临时使用conda安装依赖

若pip问题暂时无法解决,可直接通过conda安装所需库:

conda install pandas

内容的提问来源于stack exchange,提问作者Md Hafizur Rahman

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 20:14:54