zoukankan      html  css  js  c++  java
  • mumpy,h5py和tensorflow版本不匹配导致报错

     自己开发了一个股票智能分析软件,功能很强大,需要的点击下面的链接获取:

    https://www.cnblogs.com/bclshuai/p/11380657.html

    1.问题描述

    一开始用pycharm,tensorflow2.0,去编写卷积神经网络的代码,是可以正常运行的,过了几天去编译又报错了。

    1.1numpy版本报错

    D:Anaconda3envs ensorflowpython.exe D:/Project/python/tensorflow/venv/src/CNN.py
    D:Anaconda3envs ensorflowlibsite-packages umpy\__init__.py:143: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
    from . import _distributor_init
    D:Anaconda3envs ensorflowlibsite-packages umpy\__init__.py:143: UserWarning: mkl-service package failed to import, therefore Intel(R) MKL initialization ensuring its correct out-of-the box operation under condition when Gnu OpenMP had already been loaded by Python process is not assured. Please install mkl-service package, see http://github.com/IntelPython/mkl-service
    from . import _distributor_init
    Traceback (most recent call last):
    File "D:Anaconda3envs ensorflowlibsite-packages umpycore\__init__.py", line 22, in <module>
    from . import multiarray
    File "D:Anaconda3envs ensorflowlibsite-packages umpycoremultiarray.py", line 12, in <module>
    from . import overrides
    File "D:Anaconda3envs ensorflowlibsite-packages umpycoreoverrides.py", line 7, in <module>
    from numpy.core._multiarray_umath import (
    ImportError: DLL load failed: 找不到指定的模块。

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
    File "D:/Project/python/tensorflow/venv/src/CNN.py", line 1, in <module>
    import tensorflow as tf
    File "D:Anaconda3envs ensorflowlibsite-packages ensorflow\__init__.py", line 41, in <module>
    from tensorflow.python.tools import module_util as _module_util
    File "D:Anaconda3envs ensorflowlibsite-packages ensorflowpython\__init__.py", line 40, in <module>
    from tensorflow.python.eager import context
    File "D:Anaconda3envs ensorflowlibsite-packages ensorflowpythoneagercontext.py", line 29, in <module>
    import numpy as np
    File "D:Anaconda3envs ensorflowlibsite-packages umpy\__init__.py", line 145, in <module>
    from . import core
    File "D:Anaconda3envs ensorflowlibsite-packages umpycore\__init__.py", line 48, in <module>
    raise ImportError(msg)
    ImportError:

    IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

    Importing the numpy C-extensions failed. This error can happen for
    many reasons, often due to issues with your setup or how NumPy was
    installed.

    We have compiled some common reasons and troubleshooting tips at:

    https://numpy.org/devdocs/user/troubleshooting-importerror.html

    Please note and check the following:

    * The Python version is: Python3.7 from "D:Anaconda3envs ensorflowpython.exe"
    * The NumPy version is: "1.20.2"

    and make sure that they are the versions you expect.
    Please carefully study the documentation linked above for further help.

    Original error was: DLL load failed: 找不到指定的模块。


    Process finished with exit code 1

    1.2h5py版本报错

    D:Anaconda3envs ensorflowpython.exe D:/Project/python/tensorflow/venv/src/MoblieNetModel.py
    Traceback (most recent call last):
    File "D:/Project/python/tensorflow/venv/src/MoblieNetModel.py", line 1, in <module>
    import tensorflow as tf
    File "D:Anaconda3envs ensorflowlibsite-packages ensorflow\__init__.py", line 41, in <module>
    from tensorflow.python.tools import module_util as _module_util
    File "D:Anaconda3envs ensorflowlibsite-packages ensorflowpython\__init__.py", line 47, in <module>
    from tensorflow.python import keras
    File "D:Anaconda3envs ensorflowlibsite-packages ensorflowpythonkeras\__init__.py", line 27, in <module>
    from tensorflow.python.keras import models
    File "D:Anaconda3envs ensorflowlibsite-packages ensorflowpythonkerasmodels.py", line 26, in <module>
    from tensorflow.python.keras.engine import functional
    File "D:Anaconda3envs ensorflowlibsite-packages ensorflowpythonkerasenginefunctional.py", line 38, in <module>
    from tensorflow.python.keras.engine import training as training_lib
    File "D:Anaconda3envs ensorflowlibsite-packages ensorflowpythonkerasengine raining.py", line 53, in <module>
    from tensorflow.python.keras.saving import hdf5_format
    File "D:Anaconda3envs ensorflowlibsite-packages ensorflowpythonkerassavinghdf5_format.py", line 41, in <module>
    import h5py
    File "D:Anaconda3envs ensorflowlibsite-packagesh5py\__init__.py", line 34, in <module>
    from . import version
    File "D:Anaconda3envs ensorflowlibsite-packagesh5pyversion.py", line 17, in <module>
    from . import h5 as _h5
    File "h5pyh5.pyx", line 41, in init h5py.h5
    AttributeError: type object 'h5py.h5.H5PYConfig' has no attribute '__reduce_cython__'

    Process finished with exit code 1

    2.问题分析

    pycharm会对库 版本更新,升级新的版本,导致版本不匹配。

    3.解决方案

    还原到原来的版本

    (1)打开anconda prompt命令行

    (2)输入activate tensorflow激活tensorflow环境

    (base) C:Usersaochunlei>activate tensorflow

    (3)先输入pip uninstall numpy卸载

    (tensorflow) C:Usersaochunlei>pip uninstall numpy
    Found existing installation: numpy 1.20.2
    Uninstalling numpy-1.20.2:
    Would remove:
    d:anaconda3envs ensorflowlibsite-packages umpy-1.20.2.dist-info*
    d:anaconda3envs ensorflowlibsite-packages umpy*
    d:anaconda3envs ensorflowscriptsf2py-script.py
    d:anaconda3envs ensorflowscriptsf2py.exe
    Would not remove (might be manually added):
    d:anaconda3envs ensorflowlibsite-packages umpy.libslibopenblas.PYQHXLVVQ7VESDPUVUADXEVJOBGHJPAY.gfortran-win_amd64.dll
    d:anaconda3envs ensorflowlibsite-packages umpycore ests est_issue14735.py
    d:anaconda3envs ensorflowlibsite-packages umpydistutilscompat.py
    d:anaconda3envs ensorflowlibsite-packages umpy andom\_bit_generator.cp37-win_amd64.pyd
    d:anaconda3envs ensorflowlibsite-packages umpy andom\_bit_generator.pxd
    Proceed (y/n)? y
    Successfully uninstalled numpy-1.20.2

    (4)再输入pip install numpy==1.18.5安装指定低版本的numpy

    (tensorflow) C:Usersaochunlei>pip install numpy==1.18.5
    Looking in indexes: http://pypi.douban.com/simple
    Collecting numpy==1.18.5
    Downloading http://pypi.doubanio.com/packages/e4/01/7a26148f7de9eb6c27f95b29eba16b7e820827cb9ebaae182d7483e44711/numpy-1.18.5-cp37-cp37m-win_amd64.whl (12.7 MB)
    |████████████████████████████████| 12.7 MB 930 kB/s
    Installing collected packages: numpy
    Attempting uninstall: numpy
    Found existing installation: numpy 1.20.2
    Uninstalling numpy-1.20.2:
    Successfully uninstalled numpy-1.20.2
    ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
    tensorflow 2.3.1 requires h5py<2.11.0,>=2.10.0, but you have h5py 3.3.0 which is incompatible.
    tensorflow 2.3.1 requires tensorflow-estimator<2.4.0,>=2.3.0, but you have tensorflow-estimator 2.5.0 which is incompatible.
    Successfully installed numpy-1.18.5

    (5)卸载pip uninstall h5py

    (tensorflow) C:Usersaochunlei>pip uninstall h5py
    Found existing installation: h5py 3.3.0
    Uninstalling h5py-3.3.0:
    Would remove:
    d:anaconda3envs ensorflowlibsite-packagesh5py-3.3.0.dist-info*
    d:anaconda3envs ensorflowlibsite-packagesh5py*
    Would not remove (might be manually added):
    d:anaconda3envs ensorflowlibsite-packagesh5pyhighlevel.py
    d:anaconda3envs ensorflowlibsite-packagesh5py ests est_deprecation.py
    d:anaconda3envs ensorflowlibsite-packagesh5py ests est_threads.py
    Proceed (y/n)? y
    Successfully uninstalled h5py-3.3.0

    (6)安装pip install h5py==2.10.0

    (tensorflow) C:Usersaochunlei>pip install h5py==2.10.0
    Looking in indexes: http://pypi.douban.com/simple
    Requirement already satisfied: h5py==2.10.0 in d:anaconda3envs ensorflowlibsite-packages (2.10.0)
    Requirement already satisfied: six in d:anaconda3envs ensorflowlibsite-packages (from h5py==2.10.0) (1.16.0)
    Requirement already satisfied: numpy>=1.7 in d:anaconda3envs ensorflowlibsite-packages (from h5py==2.10.0) (1.18.5)

    (tensorflow) C:Usersaochunlei>pip install h5py==2.10.0
    Looking in indexes: http://pypi.douban.com/simple
    Requirement already satisfied: h5py==2.10.0 in d:anaconda3envs ensorflowlibsite-packages (2.10.0)
    Requirement already satisfied: six in d:anaconda3envs ensorflowlibsite-packages (from h5py==2.10.0) (1.16.0)
    Requirement already satisfied: numpy>=1.7 in d:anaconda3envs ensorflowlibsite-packages (from h5py==2.10.0) (1.18.5)

    (7)问题解决

    自己开发了一个股票智能分析软件,功能很强大,需要的点击下面的链接获取: https://www.cnblogs.com/bclshuai/p/11380657.html
  • 相关阅读:
    Ajax学习笔记3种Ajax的实现
    分页学习笔记真分页和假分页实现
    学习笔记链表练习,模仿StringBuilder的山寨版StringBuilder
    学习笔记将Asp.Net网站发布到IIS的四种方法及注意事项
    3D 音频技术产品介绍(1):Iosono the future of spatial audio
    国际顶级语音信号增强工作组:IWAENC(International Workshop on Acoustic Echo and Noise Control)
    转:《欢聚时代(多玩YY)IPO招股书》(概要)
    苏州阔地网络科技有限公司专利分析
    CELT和SILK以及Opus的位分配方法
    ISAC 码流格式
  • 原文地址:https://www.cnblogs.com/bclshuai/p/14963609.html
Copyright © 2011-2022 走看看