Windows10下VSCode新venv环境无法安装TensorFlow求助
TensorFlow安装提示"找不到匹配发行版本"的解决办法
问题描述
在Windows 10的VSCode中使用全新venv虚拟环境,安装matplotlib成功,但安装TensorFlow(包括指定2.14.0版本)时失败,报错找不到匹配版本。命令执行日志如下:
(.venv) PS D:\PY_Projects\Test> pip install matplotlib Collecting matplotlib Using cached matplotlib-3.8.2-cp312-cp312-win_amd64.whl.metadata (5.9 kB) Collecting contourpy>=1.0.1 (from matplotlib) Using cached contourpy-1.2.0-cp312-cp312-win_amd64.whl.metadata (5.8 kB) Collecting cycler>=0.10 (from matplotlib) .... .... Installing collected packages: six, pyparsing, pillow, packaging, numpy, kiwisolver, fonttools, cycler, python-dateutil, contourpy, matplotlib Successfully installed contourpy-1.2.0 cycler-0.12.1 fonttools-4.47.0 kiwisolver-1.4.5 matplotlib-3.8.2 numpy-1.26.3 packaging-23.2 pillow-10.2.0 pyparsing-3.1.1 python-dateutil-2.8.2 six-1.16.0 (.venv) PS D:\PY_Projects\Test> pip install tensorflow ERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none) ERROR: No matching distribution found for tensorflow (.venv) PS D:\PY_Projects\Test> pip install tensorflow==2.14.0 ERROR: Could not find a version that satisfies the requirement tensorflow==2.14.0 (from versions: none) ERROR: No matching distribution found for tensorflow==2.14.0
核心原因
从日志里的matplotlib-3.8.2-cp312-cp312-win_amd64.whl可以明确:你当前虚拟环境使用的是Python 3.12,但TensorFlow的版本支持范围不匹配:
- TensorFlow 2.14.0仅支持Python 3.8~3.11,完全不兼容Python 3.12
- matplotlib已经完成了Python 3.12的适配,所以能正常安装
解决办法
方案1:降级Python到3.11(适配TensorFlow 2.14.0)
- 退出当前虚拟环境,删除
.venv文件夹 - 安装Python 3.11版本(安装时务必勾选"Add Python to PATH")
- 重新创建虚拟环境:
python -m venv .venv - 激活环境后安装指定版本:
pip install tensorflow==2.14.0
方案2:安装支持Python 3.12的TensorFlow版本
直接安装2.15.0及以上版本,这些版本已经适配Python 3.12:
pip install tensorflow>=2.15.0
内容的提问来源于stack exchange,提问作者Jos S
相关产品推荐
相关产品推荐

