无法在visual studio代码中使用tensorflow和keras库

2024-09-29 20:31:51 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在构建一个深度学习应用程序,为此我需要在VSC中导入tensorflow和keras库,但不幸的是,尽管我已成功安装tensorflow,但无法导入它。我还检查了虚拟环境中的包(pip列表),它就在那里。我几乎什么都试过了,但还没有找到解决办法

错误:

    Traceback (most recent call last):
      File "C:\Users\Rupak\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
        from tensorflow.python.pywrap_tensorflow_internal import *
      File "C:\Users\Rupak\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
        _pywrap_tensorflow_internal = swig_import_helper()
      File "C:\Users\Rupak\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
        _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
      File "C:\Users\Rupak\Anaconda3\lib\imp.py", line 242, in load_module
        return load_dynamic(name, filename, file)
      File "C:\Users\Rupak\Anaconda3\lib\imp.py", line 342, in load_dynamic
        return _load(spec)
    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 "<stdin>", line 1, in <module>
      File "C:\Users\Rupak\Anaconda3\lib\site-packages\tensorflow\__init__.py", line 41, in <module>
        from tensorflow.python.tools import module_util as _module_util
      File "C:\Users\Rupak\Anaconda3\lib\site-packages\tensorflow\python\__init__.py", line 50, in <module>
        from tensorflow.python import pywrap_tensorflow
      File "C:\Users\Rupak\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 69, in <module>
        raise ImportError(msg)
    ImportError: Traceback (most recent call last):
      File "C:\Users\Rupak\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow.py", line 58, in <module>
        from tensorflow.python.pywrap_tensorflow_internal import *
      File "C:\Users\Rupak\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 28, in <module>
        _pywrap_tensorflow_internal = swig_import_helper()
      File "C:\Users\Rupak\Anaconda3\lib\site-packages\tensorflow\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
        _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
      File "C:\Users\Rupak\Anaconda3\lib\imp.py", line 242, in load_module
        return load_dynamic(name, filename, file)
      File "C:\Users\Rupak\Anaconda3\lib\imp.py", line 342, in load_dynamic
        return _load(spec)
    ImportError: DLL load failed: The specified module could not be found.
    
    
    Failed to load the native TensorFlow runtime.
    
    See https://www.tensorflow.org/install/errors

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

Tags: inpylibpackagestensorflowlinesiteload
2条回答

我不确定您是否创建了this页面,但此页面似乎为您的问题提供了一些解决方案。如果你没有找到它,你最好小心输出提供的信息。正如上面所说:https://www.tensorflow.org/install/errors

看起来你在一起使用conda和pip。最好不要混合使用to,所以我要么切换到虚拟环境,然后再次尝试安装,要么坚持使用conda并使用conda本身安装tensorflow

相关问题 更多 >

    热门问题