当前位置: 首页 > news >正文

anaconda安装tensorflow遇到的一个错误

笔者在conda环境 python=3.8安装tensorflow-2.5.0,因为这个2.5.0版本与笔者的CUDA版本是匹配的,结果安装好后,在python环境里执行“import tensorflow as tf”就报了一大堆错误:

(keras) C:\Users\daniel>python
Python 3.8.5 (default, Sep  3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):File "C:\Users\daniel\anaconda3\envs\keras\lib\site-packages\numpy\__init__.py", line 320, in __getattr__raise AttributeError("module {!r} has no attribute "
AttributeError: module 'numpy' has no attribute 'typeDict'
C:\Users\daniel\anaconda3\envs\keras\lib\site-packages\tensorflow\python\framework\dtypes.py:511: FutureWarning: In the future `np.object` will be defined as the corresponding NumPy scalar.np.object,
Traceback (most recent call last):File "<stdin>", line 1, in <module>File "C:\Users\daniel\anaconda3\envs\keras\lib\site-packages\tensorflow\__init__.py", line 41, in <module>from tensorflow.python.tools import module_util as _module_utilFile "C:\Users\daniel\anaconda3\envs\keras\lib\site-packages\tensorflow\python\__init__.py", line 46, in <module>from tensorflow.python import dataFile "C:\Users\daniel\anaconda3\envs\keras\lib\site-packages\tensorflow\python\data\__init__.py", line 25, in <module>from tensorflow.python.data import experimentalFile "C:\Users\daniel\anaconda3\envs\keras\lib\site-packages\tensorflow\python\data\experimental\__init__.py", line 99, in <module>from tensorflow.python.data.experimental import serviceFile "C:\Users\daniel\anaconda3\envs\keras\lib\site-packages\tensorflow\python\data\experimental\service\__init__.py", line 140, in <module>from tensorflow.python.data.experimental.ops.data_service_ops import distributeFile "C:\Users\daniel\anaconda3\envs\keras\lib\site-packages\tensorflow\python\data\experimental\ops\data_service_ops.py", line 25, in <module>from tensorflow.python.data.experimental.ops import compression_opsFile "C:\Users\daniel\anaconda3\envs\keras\lib\site-packages\tensorflow\python\data\experimental\ops\compression_ops.py", line 20, in <module>from tensorflow.python.data.util import structureFile "C:\Users\daniel\anaconda3\envs\keras\lib\site-packages\tensorflow\python\data\util\structure.py", line 26, in <module>from tensorflow.python.data.util import nestFile "C:\Users\daniel\anaconda3\envs\keras\lib\site-packages\tensorflow\python\data\util\nest.py", line 40, in <module>from tensorflow.python.framework import sparse_tensor as _sparse_tensorFile "C:\Users\daniel\anaconda3\envs\keras\lib\site-packages\tensorflow\python\framework\sparse_tensor.py", line 28, in <module>from tensorflow.python.framework import constant_opFile "C:\Users\daniel\anaconda3\envs\keras\lib\site-packages\tensorflow\python\framework\constant_op.py", line 29, in <module>from tensorflow.python.eager import executeFile "C:\Users\daniel\anaconda3\envs\keras\lib\site-packages\tensorflow\python\eager\execute.py", line 27, in <module>from tensorflow.python.framework import dtypesFile "C:\Users\daniel\anaconda3\envs\keras\lib\site-packages\tensorflow\python\framework\dtypes.py", line 511, in <module>np.object,File "C:\Users\daniel\anaconda3\envs\keras\lib\site-packages\numpy\__init__.py", line 305, in __getattr__raise AttributeError(__former_attrs__[attr])
AttributeError: module 'numpy' has no attribute 'object'.
`np.object` was a deprecated alias for the builtin `object`. To avoid this error in existing code, use `object` by itself. Doing this will not modify any behavior and is safe.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

从错误的提示看来是numpy版本不匹配,这里的numpy版本是1.24.3,有点高了。于是降级也不成,因为numpy被一大堆安装包所依赖,删除numpy会删除几乎整个tensorflow环境。在网上搜索了一番,于是尝试降低python版本为3.6,再安装tensorflow-2.5.0,结果import tensorflow时,直接报python版本不匹配,于是在python版本3.7下再安装tensorflow-2.5.0,导入tensorflow时,没有报错,整个过程简直就是恶作剧一场!半天时间就这么没了。

Python 3.7.16 (default, Jan 17 2023, 16:06:28) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> tf.__version__
'2.5.0'
>>> import numpy as np
>>> np.__version__
'1.21.5'

http://www.dtcms.com/a/394356.html

相关文章:

  • 不同浏览器对 http.server 提供MP4 文件支持差异分析
  • Python 实战:内网渗透中的信息收集自动化脚本(10)
  • leetcode 206 反转链表
  • AI智能的网站SEO优化服务商
  • 生产者客户端
  • Puppeteer 在爬取电商 JavaScript 页面的使用
  • 2015/12 JLPT听力原文 问题四
  • 【设计模式】备忘录模式
  • STM32_07_按键
  • 基于迁移学习和SqueezeNet的滚动轴承故障诊断(MATLAB)
  • 实战项目(十二:《AI画质增强与LED驱动控制:一场关于‘创造’与‘还原’的对话》):从LED冬奥会、奥运会及春晚等大屏,到手机小屏,快来挖一挖里面都有什么
  • 开发避坑指南(52):IDEA 2025.1.3 顶部显示类完整路径的设置方法
  • 安装Qt新之后出现两本帮助手册
  • Rust_2025:阶段1:day7.2unsafe , 链接相关
  • 【论文速递】2025年第15周(Apr-06-12)(Robotics/Embodied AI/LLM)
  • 设计模式简单说明:责任链与规则树
  • 自动备份脚本 mysql_hourly_backup.sh
  • SuperGLUE:自然语言理解的挑战与进步
  • 线程安全的单例模式、自旋锁,以及读者写者问题
  • U盘长期插在电脑上的影响
  • Windows 系统部署 PaddleOCR —— 基于 EPGF 架构
  • 数据一致性指的是什么?如何实现数据一致性?
  • 初识消息队列的世界
  • Python快速入门专业版(三十八):Python字典:键值对结构的增删改查与进阶用法
  • SpringCloudOAuth2+JWT:微服务统⼀认证方案
  • LeetCode 分类刷题:2517. 礼盒的最大甜蜜度
  • 深度学习优化器进阶:从SGD到AdamW,不同优化器的适用场景
  • C++ 之 【C++的IO流】
  • truffle学习笔记
  • 现代循环神经网络