[英]Importing tensorflow makes python 3.6.5 error
Tensorflow used to work on my computer. Tensorflow曾经在我的电脑上工作。 But now when I try to
import tensorflow
python itself errors out. 但是现在当我尝试
import tensorflow
python本身错误时。 I am not given a traceback call to tell me what the error is. 我没有收到追溯电话,告诉我错误是什么。 I get a window's prompt that says "Python has stopped working".
我得到一个窗口的提示,上面写着“Python已停止工作”。 When I click "debug" all I get is "An unhandled win32 exception occurred in python.exe".
当我点击“debug”时,我得到的是“python.exe中发生未处理的win32异常”。 I've never had a python package actually error out python itself for me, I've always just had a traceback error thrown by python if I didn't install something right.
我从来没有一个python包实际上错误输出python本身对我来说,如果我没有安装正确的东西,我总是只有python引发的回溯错误。
I've tried uninstalling and reinstalling tensorflow (effectively updating from 1.7.0 to 1.12.0) but that has not helped. 我已经尝试卸载并重新安装张量流(有效地从1.7.0更新到1.12.0),但这没有帮助。 I'm not sure how to search for a solution to this problem either since I'm not given a traceback or an error code or an error message aside from the very generic one above.
我不知道如何搜索这个问题的解决方案,因为我没有给出回溯或错误代码或错误消息,除了上面非常通用的一个。
I'm currently using python 3.6.5 with tensorflow 1.12.0 (CPU only) installed. 我目前正在使用安装了tensorflow 1.12.0(仅限CPU)的python 3.6.5。 My OS is Windows 7 Enterprise 64 bit.
我的操作系统是Windows 7 Enterprise 64位。
Any ideas? 有任何想法吗?
EDIT: The python distro I am using is through Anaconda and I'm trying to run python directly through the anaconda prompt (command line interface). 编辑:我正在使用的python发行版是通过Anaconda,我试图直接通过anaconda提示符(命令行界面)运行python。
EDIT2: I used the faulthandler
module to see if I can get a stack trace out of it, and I got a Windows fatal exception: code 0xc0000139
and a Windows fatal exception: access violation
, along with a bunch of lines linking to various frozen importlib._bootstrap
lines of code in various __init__.py
modules. EDIT2:我使用了
faulthandler
模块来查看是否可以从中获取堆栈跟踪,并且我遇到了Windows fatal exception: code 0xc0000139
和Windows fatal exception: access violation
,以及链接到各种frozen importlib._bootstrap
的一堆行frozen importlib._bootstrap
各种__init__.py
模块中的代码行。
EDIT3: For a bit more context, this is on a workplace machine with a lot of security software installed on it. 编辑3:对于更多的上下文,这是在工作场所机器上安装了许多安全软件。
I have solved the issue. 我已经解决了这个问题。 The following procedure was used to find and fix the problem:
以下过程用于查找和修复问题:
I used the faulthandler
module to force python to print out a stack trace and recieved a Windows fatal exception: access violation
error which seems to suggest the problem was indeed a segfault caused by some module used by tensorflow. 我使用
faulthandler
模块强制python打印出堆栈跟踪并收到Windows fatal exception: access violation
错误,这似乎表明问题确实是由tensorflow使用的某些模块引起的段错误。
I tried to fix dependencies by doing a conda update --all
and then a conda clean --all
which didn't fix the problem. 我试图通过做一个
conda update --all
来修复依赖关系 - 所有然后一个conda clean --all
并没有解决问题。
I noticed though that the problems seems to arise from the h5py
and keras
modules so I did pip install --upgrade h5py
and pip install --upgrade keras
and pip install --upgrade tensorflow
and the problem was fixed. 我注意到问题似乎来自
h5py
和keras
模块所以我做了pip install --upgrade h5py
和pip install --upgrade keras
pip install --upgrade h5py
pip install --upgrade keras
和pip install --upgrade tensorflow
并且问题得到解决。 I am now using tensorflow version 1.12.0
, keras version 2.2.4
, and h5py version 2.8.0
. 我现在使用
tensorflow version 1.12.0
, keras version 2.2.4
和h5py version 2.8.0
。
The key to solving this problem seems to be the faulthander
module which showed me which modules (h5py and keras) were leading to the segfault. 解决这个问题的关键似乎是
faulthander
模块,它向我展示了哪些模块(h5py和keras)导致了段错误。
Please try following Steps 请尝试以下步骤
conda install -c anaconda qt
conda update qt pyqt
start again 重新开始
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.