在 Anaconda 的 Windows 上安装 witwidget(google what-if too)时面临问题

Posted

技术标签:

【中文标题】在 Anaconda 的 Windows 上安装 witwidget(google what-if too)时面临问题【英文标题】:Facing issue with installation of witwidget (google what-if too) on Windows in Anaconda 【发布时间】:2020-07-31 07:50:46 【问题描述】:

我在安装 What-If 工具时遇到问题。

pip install tensorflow 成功完成。

pip install witwidget 成功完成。

jupyter nbextension install --py --symlink --sys-prefix witwidget 失败并出现以下错误)

环境: Windows 10 Python 版本: 3.7.0
(base) C:\Users\ankitagarwal5>jupyter nbextension install --py --symlink --sys-prefix witwidget
Traceback (most recent call last):
  File "C:\Users\ankitagarwal5\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\ankitagarwal5\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\ankitagarwal5\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "C:\Users\ankitagarwal5\AppData\Local\Continuum\anaconda3\lib\imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Users\ankitagarwal5\AppData\Local\Continuum\anaconda3\lib\imp.py", line 343, 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 "C:\Users\ankitagarwal5\AppData\Local\Continuum\anaconda3\Scripts\jupyter-nbextension-script.py", line 10, in <module>
    sys.exit(main())
  File "C:\Users\ankitagarwal5\AppData\Local\Continuum\anaconda3\lib\site-packages\jupyter_core\application.py", line 266, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "C:\Users\ankitagarwal5\AppData\Local\Continuum\anaconda3\lib\site-packages\traitlets\config\application.py", line 658, in launch_instance
    app.start()
  File "C:\Users\ankitagarwal5\AppData\Local\Continuum\anaconda3\lib\site-packages\notebook\nbextensions.py", line 988, in start
    super(NBExtensionApp, self).start()
  File "C:\Users\ankitagarwal5\AppData\Local\Continuum\anaconda3\lib\site-packages\jupyter_core\application.py", line 255, in start
    self.subapp.start()
  File "C:\Users\ankitagarwal5\AppData\Local\Continuum\anaconda3\lib\site-packages\notebook\nbextensions.py", line 716, in start
    self.install_extensions()
  File "C:\Users\ankitagarwal5\AppData\Local\Continuum\anaconda3\lib\site-packages\notebook\nbextensions.py", line 695, in install_extensions
    **kwargs
  File "C:\Users\ankitagarwal5\AppData\Local\Continuum\anaconda3\lib\site-packages\notebook\nbextensions.py", line 211, in install_nbextension_python
    m, nbexts = _get_nbextension_metadata(module)
  File "C:\Users\ankitagarwal5\AppData\Local\Continuum\anaconda3\lib\site-packages\notebook\nbextensions.py", line 1122, in _get_nbextension_metadata
    m = import_item(module)
  File "C:\Users\ankitagarwal5\AppData\Local\Continuum\anaconda3\lib\site-packages\traitlets\utils\importstring.py", line 42, in import_item
    return __import__(parts[0])
  File "C:\Users\ankitagarwal5\AppData\Local\Continuum\anaconda3\lib\site-packages\witwidget\__init__.py", line 15, in <module>
    from witwidget.notebook.visualization import *
  File "C:\Users\ankitagarwal5\AppData\Local\Continuum\anaconda3\lib\site-packages\witwidget\notebook\visualization.py", line 17, in <module>
    import tensorflow as tf
  File "C:\Users\ankitagarwal5\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\__init__.py", line 101, in <module>
    from tensorflow_core import *
  File "C:\Users\ankitagarwal5\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow_core\__init__.py", line 40, in <module>
    from tensorflow.python.tools import module_util as _module_util
  File "C:\Users\ankitagarwal5\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\__init__.py", line 50, in __getattr__
    module = self._load()
  File "C:\Users\ankitagarwal5\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\__init__.py", line 44, in _load
    module = _importlib.import_module(self.__name__)
  File "C:\Users\ankitagarwal5\AppData\Local\Continuum\anaconda3\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "C:\Users\ankitagarwal5\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow_core\python\__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "C:\Users\ankitagarwal5\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "C:\Users\ankitagarwal5\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow_core\python\pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "C:\Users\ankitagarwal5\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "C:\Users\ankitagarwal5\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "C:\Users\ankitagarwal5\AppData\Local\Continuum\anaconda3\lib\imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "C:\Users\ankitagarwal5\AppData\Local\Continuum\anaconda3\lib\imp.py", line 343, 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.

【问题讨论】:

实际上,您不应该使用基本环境。您是否尝试过创建虚拟环境来安装软件包? 我还没有创建虚拟环境。我在基本环境中尝试过。如果我创建虚拟环境,我可以通过 Jupyter Anaconda 使用它吗? 如果你在虚拟环境中安装 Jupyter,可以。 对不起,我忘了问,您使用的是 Miniconda 还是 Anaconda?如果使用 Anaconda,它会在基础环境中安装所有内容。就个人而言,我使用 Miniconda 并将所有东西安装在虚拟环境中,基础环境非常小。请参阅***.com/a/56504279 另请参阅github.com/tensorflow/tensorflow/issues/22794 您可能需要安装 MSVC 可再发行组件。 我正在使用 Anaconda,所以想知道为什么在基本环境中安装了所有东西后仍然会出现此错误。在继续使用基本 Anaconda 环境的同时更正此问题的任何建议? 【参考方案1】:

我能够解决这个问题,这似乎主要是由于 tensorflow 版本。下面是我使用 Anaconda Python (v3.7) 在我的 Windows 笔记本电脑上安装 witwidget 所遵循的步骤

pip 安装 pyhamcrest 点安装谷歌身份验证 conda 更新包装

现在是重要的部分。如果 tensorflow 版本 > 2.0,则需要卸载它。所以尝试运行这个命令来安装 tensorflow v 2.0

pip install tensorflow==2.0.0

然后执行这些命令就可以了

pip 安装witwidget jupyter nbextension install --py --symlink --sys-prefix witwidget jupyter nbextension enable --py --sys-prefix witwidget

谢谢!

【讨论】:

以上是关于在 Anaconda 的 Windows 上安装 witwidget(google what-if too)时面临问题的主要内容,如果未能解决你的问题,请参考以下文章

在Windows 10上安装Anaconda2

windows上安装Anaconda和python

如何在Anaconda / PyCharm Windows 10上安装TFLearn?

windows上安装Anaconda和python

使用 Anaconda (Python) 在 Windows 上安装 Pyomo

ubuntu 和windows 分别在anaconda上安装tensorflow