首页 > 解决方案 > AttributeError:module 'imp' has no attribute 'find_module'

问题描述

I used this code to import in VSCODE editor.
Getting error as below.
Already installed tensorflow by pip install tensorflow in command line.
Any help please?

import tensorflow  

File "C:\Users\david\python3_6\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 18, in swig_import_helper
    fp, pathname, description = imp.find_module('_pywrap_tensorflow_internal', [dirname(__file__)])
AttributeError: module 'imp' has no attribute 'find_module'

标签: pythontensorflow

解决方案


当我的工作目录包含同名的自定义文件(“imp.py”)时,我遇到了这样的问题。也许,您的项目也包含这样的文件 :) 只需找到并打开引发错误的文件,然后 Ctrl+单击“imp”模块以在单独的选项卡中打开它,看看有什么问题。


推荐阅读