简体   繁体   English

导入tensorflow会导致python 3.6.5错误

[英]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 0xc0000139Windows 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. 我注意到问题似乎来自h5pykeras模块所以我做了pip install --upgrade h5pypip install --upgrade keras pip install --upgrade h5py pip install --upgrade keraspip 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.0keras version 2.2.4h5py 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.

相关问题 TensorFlow 1.9.0 和 Python 3.6.5 - TensorFlow 1.9.0 and Python 3.6.5 Python 导入错误 Tensorflow 2. Keras - Python error in importing Tensorflow 2 . Keras Ubuntu16.04 python3.6.5无法安装TensorFlow - Ubuntu16.04 python3.6.5 cannot install tensorflow 导入tensorflow(刚刚安装)python 3.7时出错 - Error importing tensorflow (just installed) python 3.7 导入张量流时出错:NameError: name 'python' 未定义 - Error importing tensorflow: NameError: name 'python' is not defined 在带有导入的简单python代码中导入tensorflow时出错 - Error importing tensorflow in simple python code with import 导入tensorflow时出错(python 3.6x) - Error in importing tensorflow ( python 3.6x ) 在Windows上导入Python中的TensorFlow时出错 - Error when importing TensorFlow in Python on Windows 我安装了Tensorflow gpu版本以及CUDA 9.1和python 3.6.5。 但是,在导入tensorflow-gpu之后,出现以下错误: - I installed the Tensorflow gpu version and CUDA 9.1 and python 3.6.5. However, after I import the tensorflow-gpu I got the following error: 如何使用 Python 3.6.5 在 TensorFlow Keras API 中修复“ModuleNotFoundError:没有名为“tensorflow._api”的模块 - How to fix 'ModuleNotFoundError: No module named 'tensorflow._api' in TensorFlow Keras API with Python 3.6.5
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM