GVKun编程网logo

Tensorflow ImportError:Windows 10上没有名为'_pywrap_tensorflow_internal'的模块(tensorflow没有compat该属性)

19

此处将为大家介绍关于TensorflowImportError:Windows10上没有名为'_pywrap_tensorflow_internal'的模块的详细内容,并且为您解答有关tensorfl

此处将为大家介绍关于Tensorflow ImportError:Windows 10上没有名为'_pywrap_tensorflow_internal'的模块的详细内容,并且为您解答有关tensorflow没有compat该属性的相关问题,此外,我们还将为您介绍关于anaconda 安装 tensorflow 报错 No module named ''tensorflow'' 解决方法 (windows)、Apache Airflow:airflow initdb导致“ ImportError:没有名为json的模块”、bazel 编译 tensorflow 生成 libtensorflow_inference.so 和 libandroid_tensorflow_inference_java.jar、ImportError: No module named ''_pywrap_tensorflow''的有用信息。

本文目录一览:

Tensorflow ImportError:Windows 10上没有名为'_pywrap_tensorflow_internal'的模块(tensorflow没有compat该属性)

Tensorflow ImportError:Windows 10上没有名为'_pywrap_tensorflow_internal'的模块(tensorflow没有compat该属性)

如何解决Tensorflow ImportError:Windows 10上没有名为''_pywrap_tensorflow_internal''的模块?

您需要安装cudnn。目前仅正式支持5.1版。不知道6.0的重命名技巧是否在以下位置提及:

无法在Windows 10上为GPU导入Tensorflow

解决方法

我正在与Udacity合作进行自动驾驶课程。我在Windows 10中启动了一个通用环境,我能够很好地运行tensorflow,但我想使用GPU。

我的GPU被列为兼容(GTX 950M)。

我按照Windows 10上的tensorflow指令添加了GPU:

https://www.tensorflow.org/install/install_windows

并下载并安装了cuda_8.0.61_win10

接下来,我重新启动了环境。我检查了一下它是否在使用简单的python程序:

import tensorflow as tf

# Create TensorFlow object called tensor
hello_constant = tf.constant(''Hello World!'')

with tf.Session() as sess:
    # Run the tf.constant operation in the session
    output = sess.run(hello_constant)
    print(output)

它执行如下:

(carnd-term1) D:\SelfDrivingCar\tensor-exp>python hello.py
b''Hello World!''

接下来我安装了gpu版本的tensorflow:

(carnd-term1) D:\SelfDrivingCar\CarND-Traffic-Sign-Classifier-Project>pip install tensorflow-gpu
Collecting tensorflow-gpu
  Downloading tensorflow_gpu-1.1.0-cp35-cp35m-win_amd64.whl (48.5MB)
    100% |################################| 48.6MB 16kB/s
Requirement already satisfied: six>=1.10.0 in d:\programdata\anaconda3\envs\carnd-term1\lib\site-packages (from tensorflow-gpu)
Requirement already satisfied: protobuf>=3.2.0 in d:\programdata\anaconda3\envs\carnd-term1\lib\site-packages (from tensorflow-gpu)
Requirement already satisfied: wheel>=0.26 in d:\programdata\anaconda3\envs\carnd-term1\lib\site-packages (from tensorflow-gpu)
Requirement already satisfied: werkzeug>=0.11.10 in d:\programdata\anaconda3\envs\carnd-term1\lib\site-packages (from tensorflow-gpu)
Requirement already satisfied: numpy>=1.11.0 in d:\programdata\anaconda3\envs\carnd-term1\lib\site-packages (from tensorflow-gpu)
Requirement already satisfied: setuptools in d:\programdata\anaconda3\envs\carnd-term1\lib\site-packages (from protobuf>=3.2.0->tensorflow-gpu)
Installing collected packages: tensorflow-gpu
Successfully installed tensorflow-gpu-1.1.0

我重新运行hello.py并得到以下内容

(carnd-term1) D:\SelfDrivingCar\tensor-exp>python hello.py
Traceback (most recent call last):
  File "d:\ProgramData\Anaconda3\envs\carnd-term1\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",line 18,in swig_import_helper
    return importlib.import_module(mname)
  File "d:\ProgramData\Anaconda3\envs\carnd-term1\lib\importlib\__init__.py",line 126,in import_module
    return _bootstrap._gcd_import(name[level:],package,level)
  File "<frozen importlib._bootstrap>",line 986,in _gcd_import
  File "<frozen importlib._bootstrap>",line 969,in _find_and_load
  File "<frozen importlib._bootstrap>",line 958,in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>",line 666,in _load_unlocked
  File "<frozen importlib._bootstrap>",line 577,in module_from_spec
  File "<frozen importlib._bootstrap_external>",line 906,in create_module
  File "<frozen importlib._bootstrap>",line 222,in _call_with_frames_removed
ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception,another exception occurred:

Traceback (most recent call last):
  File "d:\ProgramData\Anaconda3\envs\carnd-term1\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",line 41,in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "d:\ProgramData\Anaconda3\envs\carnd-term1\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",line 21,in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "d:\ProgramData\Anaconda3\envs\carnd-term1\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",line 20,in swig_import_helper
    return importlib.import_module(''_pywrap_tensorflow_internal'')
  File "d:\ProgramData\Anaconda3\envs\carnd-term1\lib\importlib\__init__.py",level)
ImportError: No module named ''_pywrap_tensorflow_internal''

During handling of the above exception,another exception occurred:

Traceback (most recent call last):
  File "hello.py",line 1,in <module>
    import tensorflow as tf
  File "d:\ProgramData\Anaconda3\envs\carnd-term1\lib\site-packages\tensorflow\__init__.py",line 24,in <module>
    from tensorflow.python import *
  File "d:\ProgramData\Anaconda3\envs\carnd-term1\lib\site-packages\tensorflow\python\__init__.py",line 51,in <module>
    from tensorflow.python import pywrap_tensorflow
  File "d:\ProgramData\Anaconda3\envs\carnd-term1\lib\site-packages\tensorflow\python\pywrap_tensorflow.py",line 52,in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "d:\ProgramData\Anaconda3\envs\carnd-term1\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py",level)
ImportError: No module named ''_pywrap_tensorflow_internal''


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/install_sources#common_installation_problems

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.

我删除了环境,并使用以下命令重复了整个过程:

pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.1.0-cp35-cp35m-win_amd64.whl

并得到相同的结果。

由于列出的目录中没有名为cudnn64_6.dll的文件,因此以下命令不起作用(在Windows 10上无法导入Tensorflow forGPU)。

有什么想法为什么会发生导入错误?

anaconda 安装 tensorflow 报错 No module named ''tensorflow'' 解决方法 (windows)

anaconda 安装 tensorflow 报错 No module named ''tensorflow'' 解决方法 (windows)

这个错误的原因可能是,anaconda 安装的 python 版本为 3.7,现在 tensorflow 仅支持 python 3.6
 
改变 python 版本:首先在命令行创建一个名为 python36 的环境,指定的 Python 版本是 3.6。如下:
conda create --name python36 python=3.6
activate python36
python --version #查看 发现已经是3.6版本

现在在命令行里试一下:

python
import tensorflow

 

发现可以用了,但是在 jupyter notebook 里还是不行。
在命令行:
jupyter kernelspec list

 

给出的地址指向一个包含 kernel.json 的文件夹,打开这个 json 文件,发现里面指向的 python.exe 仍然是 python3.7,错误的原因找到了。
在命令行:
conda install jupyter notebook #重新安装Jupyter


完美解决。(用 deactivate 可以退出 Python36 环境)

Apache Airflow:airflow initdb导致“ ImportError:没有名为json的模块”

Apache Airflow:airflow initdb导致“ ImportError:没有名为json的模块”

在具有Python 2.7默认版本的Ubuntu 16.04上,我正在尝试安装Apache airflow,但是遇到了几个问题,目前我看到

apache initdb 
Traceback (most recent call last):
  File "/usr/local/bin/airflow",line 21,in <module>
    from airflow import configuration
  File "/usr/local/lib/python2.7/dist-packages/airflow/__init__.py",line 40,in <module>
    from flask_admin import BaseView
  File "/usr/local/lib/python2.7/dist-packages/flask_admin/__init__.py",line 6,in <module>
    from .base import expose,expose_plugview,Admin,BaseView,AdminIndexView  # noqa: F401
  File "/usr/local/lib/python2.7/dist-packages/flask_admin/base.py",in <module>
    from flask import Blueprint,current_app,render_template,abort,g,url_for
  File "/usr/local/lib/python2.7/dist-packages/flask/__init__.py",line 20,in <module>
    from .app import Flask
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py",line 69,in <module>
    from .wrappers import Request
  File "/usr/local/lib/python2.7/dist-packages/flask/wrappers.py",line 14,in <module>
    from werkzeug.wrappers.json import JSONMixin as _JSONMixin
ImportError: No module named json

到现在为止,尝试了以下这些事情:

$ sudo apt-get install build-essential autoconf libtool pkg-config python-opengl python-imaging python-pyrex python-pyside.qtopengl idle-python2.7 qt4-dev-tools qt4-designer libqtgui4 libqtcore4 libqt4-xml libqt4-test libqt4-script libqt4-network libqt4-dbus python-qt4 python-qt4-gl libgle3 python-dev



sudo pip install -U Werkzeug==0.14.1

sudo pip install -U Jinja2==2.10.1

也试过了

pip install jsonate

pip install json # (this did not work)




 python
Python 2.7.12 (default,Nov 12 2018,14:36:49)
[GCC 5.4.0 20160609] on linux2
Type "help","copyright","credits" or "license" for more information.
>>> import json
>>> exit()

到目前为止没有任何工作。

bazel 编译 tensorflow 生成 libtensorflow_inference.so 和 libandroid_tensorflow_inference_java.jar

bazel 编译 tensorflow 生成 libtensorflow_inference.so 和 libandroid_tensorflow_inference_java.jar

bazel build -c opt //tensorflow/contrib/android:libtensorflow_inference.so --crosstool_top=//external:android/crosstool --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --cpu=armeabi-v7a 

 

在我的机器上,对于 tf 1.0,同时自己笔记本仅仅 4G 内存:

/home/bonelee/app/bazel-0.4.2/bin/bazel build -c opt //tensorflow/contrib/android:libtensorflow_inference.so --crosstool_top=//external:android/crosstool --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --cpu=arm64-v8a
 2022  /home/bonelee/app/bazel-0.4.2/bin/bazel build -c opt //tensorflow/contrib/android:libtensorflow_inference.so --crosstool_top=//external:android/crosstool --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --cpu=arm64-v8a --local_resources=2048,.5,1.0 -j 3

 

你将在这里找到 libtensorflow_inference.so 文件:

bazel-bin/tensorflow/contrib/android/libtensorflow_inference.so 

除了 .so 文件之外,我们还需要一个 JAR 文件。运行:

bazel build  //tensorflow/contrib/android:android_tensorflow_inference_java 

你将在这里找到该文件:

bazel-bin/tensorflow/contrib/android/libandroid_tensorflow_inference_java.jar 

现在,可以将 .so 和 .jar 文件一起移到你的安卓项目中的「libs」文件夹。

 

ImportError: No module named ''_pywrap_tensorflow''

ImportError: No module named ''_pywrap_tensorflow''

ImportError: DLL load failed: 内存位置访问无效。

 

During handling of the above exception, another exception occurred:

 

Traceback (most recent call last):

File "D:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-p

ackages\tensorflow\python\__init__.py", line 66, in <module>

from tensorflow.python import pywrap_tensorflow

File "D:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-p

ackages\tensorflow\python\pywrap_tensorflow.py", line 21, in <module>

_pywrap_tensorflow = swig_import_helper()

File "D:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\site-p

ackages\tensorflow\python\pywrap_tensorflow.py", line 20, in swig_import_helper

return importlib.import_module(''_pywrap_tensorflow'')

File "D:\Users\Administrator\AppData\Local\Programs\Python\Python35\lib\import

lib\__init__.py", line 126, in import_module

return _bootstrap._gcd_import(name[level:], package, level)

ImportError: No module named ''_pywrap_tensorflow''

今天的关于Tensorflow ImportError:Windows 10上没有名为'_pywrap_tensorflow_internal'的模块tensorflow没有compat该属性的分享已经结束,谢谢您的关注,如果想了解更多关于anaconda 安装 tensorflow 报错 No module named ''tensorflow'' 解决方法 (windows)、Apache Airflow:airflow initdb导致“ ImportError:没有名为json的模块”、bazel 编译 tensorflow 生成 libtensorflow_inference.so 和 libandroid_tensorflow_inference_java.jar、ImportError: No module named ''_pywrap_tensorflow''的相关知识,请在本站进行查询。

本文标签: