Windows 11下安装tensorflow==1.15.4遇阻及运行报错求助
如何在Windows 11上安装TensorFlow==1.15.4?
已尝试操作
- 执行
pip install tensorflow-gpu==1.15.4失败,得知tensorflow-gpu已停用,需使用tensorflow主包 - 执行
pip install tensorflow==1.15.4失败,了解到TF1.15.4仅支持Python 3.5-3.7 - 安装Python 3.7.0并创建虚拟环境,执行
pip install tensorflow==1.15.4仍失败,报错:
PS C:\Users\username\Documents\Projects\project143> pip install tensorflow==1.15.4 ERROR: Could not find a version that satisfies the requirement tensorflow==1.15.4 (from versions: none) ERROR: No matching distribution found for tensorflow==1.15.4
- 从PyPI下载
tensorflow_gpu-1.15.4-cp37-cp37m-win_amd64.whl本地安装,报错:
(my_venv) PS C:\Users\username\Documents\Projects\project143> python -m pip install --upgrade .\tensorflow_gpu-1.15.4-cp37-cp37m-win_amd64.whl ERROR: tensorflow_gpu-1.15.4-cp37-cp37m-win_amd64.whl is not a supported wheel on this platform.
- 更换Python 3.6.0尝试,结果相同
- 分别使用pip 10.0.1和pip 24.0执行安装,结果一致
- 补充:Python 3.7.0下执行
pip install tensorflow也失败,报错无匹配版本
更新信息
通过pip install https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.5.0-py3-none-any.whl成功安装TensorFlow 1.15.0,但运行代码时出现模块缺失报错
解决方案
1. 确认Python版本的位数兼容性
你下载的tensorflow_gpu-1.15.4-cp37-cp37m-win_amd64.whl是64位平台专属包,必须搭配64位的Python 3.7.x。打开虚拟环境终端,执行以下命令检查:
python -c "import platform; print(platform.architecture())"
如果输出为('32bit', 'WindowsPE'),说明你安装的是32位Python,需卸载后重新安装64位Python 3.7.16(3.7系列最终稳定版)。
2. 用conda安装(最稳妥,自动处理依赖)
conda会自动匹配平台与依赖版本,避免pip的兼容性问题:
- 安装Windows 64位版Miniconda或Anaconda
- 创建并激活虚拟环境:
conda create -n tf115 python=3.7 conda activate tf115 - 添加conda-forge源(确保能检索到旧版本包):
conda config --add channels conda-forge - 安装TensorFlow 1.15.4:
conda install tensorflow=1.15.4 - 若需GPU支持,同步安装适配版本的CUDA和cuDNN(TF1.15.4对应CUDA 10.0、cuDNN 7.6):
conda install cudatoolkit=10.0 cudnn=7.6
3. 修复pip安装的问题
若坚持使用pip,先确保是64位Python,再尝试以下操作:
- 指定官方PyPI源安装,避免国内源缺失旧版本:
pip install tensorflow==1.15.4 -i https://pypi.org/simple/ - 若本地whl仍报错,将文件名改为
tensorflow-1.15.4-cp37-cp37m-win_amd64.whl(去掉_gpu后缀),再执行安装:pip install ./tensorflow-1.15.4-cp37-cp37m-win_amd64.whl
4. 模块缺失报错的排查价值
安装1.15.0后出现的模块缺失问题,可帮你确认依赖版本的匹配性。TensorFlow 1.x系列依赖特定版本的numpy(1.16.x-1.18.x)、keras(2.3.1)、protobuf(3.8.x)等,你可先安装这些依赖,再尝试安装1.15.4:
pip install numpy==1.18.5 keras==2.3.1 protobuf==3.8.0 pip install tensorflow==1.15.4 -i https://pypi.org/simple/
内容的提问来源于stack exchange,提问作者THEMOUNTAINSANDTHESKIES
相关产品推荐
相关产品推荐

