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

Python 3.8环境下安装scanpy遇依赖冲突及权限问题求助

问题说明

我使用Python 3.8版本,在Jupyter Notebook中执行pip install scanpy命令安装scanpy时,出现多组依赖版本冲突错误,同时触发[WinError 5]权限拒绝问题。已尝试在shell执行该命令、重启内核,但问题仍未解决。

错误信息

ERROR: matplotlib 3.5.3 has requirement packaging>=20.0, but you'll have packaging 19.2 which is incompatible.
ERROR: anndata 0.8.0 has requirement packaging>=20, but you'll have packaging 19.2 which is incompatible.
ERROR: pynndescent 0.5.8 has requirement importlib-metadata>=4.8.1; python_version < "3.8", but you'll have importlib-metadata 0.23 which is incompatible.
ERROR: pynndescent 0.5.8 has requirement llvmlite>=0.30, but you'll have llvmlite 0.29.0 which is incompatible.
ERROR: pynndescent 0.5.8 has requirement numba>=0.51.2, but you'll have numba 0.45.1 which is incompatible.
ERROR: umap-learn 0.5.3 has requirement numba>=0.49, but you'll have numba 0.45.1 which is incompatible.
ERROR: Could not install packages due to an EnvironmentError: [WinError 5] Access is denied: 'c:\\programdata\\anaconda3\\lib\\site-packages\\numpy\\compat\\py3k.py'
Consider using the `--user` option or check the permissions.

解决步骤

1. 优先解决权限问题

直接添加--user参数安装,绕开系统级权限限制:

  • 在终端执行:
pip install scanpy --user
  • 在Jupyter Notebook中执行(需加!):
!pip install scanpy --user

2. 手动修复依赖冲突

如果权限问题解决后仍存在依赖版本不兼容,先逐一更新冲突包:

# 更新packaging至满足最低要求的版本
pip install --user packaging>=20.0
# 更新numba和llvmlite到兼容版本
pip install --user numba>=0.51.2 llvmlite>=0.30
# 再次安装scanpy
pip install --user scanpy

3. 用虚拟环境隔离全局依赖(推荐方案)

使用Anaconda创建独立虚拟环境,彻底避免全局依赖混乱:

# 创建Python3.8的专属环境
conda create -n scanpy_env python=3.8
# 激活环境
conda activate scanpy_env
# 直接安装scanpy
pip install scanpy

若需在Jupyter Notebook中使用该环境,需先添加内核:

conda install -n scanpy_env ipykernel
python -m ipykernel install --user --name=scanpy_env

重启Notebook后,选择scanpy_env内核即可正常使用。

内容的提问来源于stack exchange,提问作者Iqra Imtiaz

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.12 16:10:23