Tensorflow在R命令行中有效,但在Rstudio中不起作用

时间:2018-12-20 10:39:05

标签: r tensorflow

我已经安装了tensorflow软件包。

以下命令在R命令行中可以正常运行

library(tensorflow)
sess = tf$Session

但是,当我在Rstudio中运行相同的2行时,出现以下错误

Error: Python module tensorflow was not found
Detected Python configuration:

...
numpy:           [NOT FOUND]

我怀疑它与numpy有关,但我不知道。

这是我的Rstudio信息

rstudio::versionInfo()
$version
[1] ‘0.98.1103’
$mode
[1] "desktop"

我需要使用其他版本的Rstudio还是需要更多设置才能使tensorflow正常工作?

阅读后有更多细节 https://github.com/rstudio/tensorflow/issues/87

import('numpy')

Error in py_module_import(module, convert = convert) : ImportError: 
Importing the multiarray numpy extension module failed.  Most
likely you are trying to import a failed build of numpy.
If you're working with a numpy git repo, try `git clean -xdf` (removes all
files not under version control).  Otherwise reinstall numpy.

Original error was: DLL load failed: The specified path is invalid.

****************最终编辑*********************

我让它起作用。但我不知道为什么或如何。 在Rstudio中的install_tensorflow()期间,系统会提示您将以下内容添加到PATH中,所以我这样做了

usr\appdata\local\programs\python\python36\Scripts

我从PATH中删除了它,并在Rstudio中成功运行了tensorflow。

但是,我随后又将其添加回了并且无法复制该错误。 最后,我仍然不知道Rstudio发生了什么或修复了什么

1 个答案:

答案 0 :(得分:0)

请使用以下命令重新加载动态库路径

<div class="swatches-select" data-id="pa_size">
  <div class="basel-swatch basel-tooltip  text-only swatch-size-large swatch-enabled" data-value="6 ½" style="">
    <span class="basel-tooltip-label">6 ½</span>6 ½
  </div>
  <div class="basel-swatch basel-tooltip  text-only swatch-size-large swatch-enabled" data-value="11" style="">
    <span class="basel-tooltip-label">11</span>11
  </div>
</div>

<div id="hidden-shoe-sizes">
  <div class="basel-swatch basel-tooltip  text-only swatch-size-large swatch-disabled"><span class="basel-tooltip-label">4</span>4</div>
  <div class="basel-swatch basel-tooltip  text-only swatch-size-large swatch-disabled"><span class="basel-tooltip-label">5</span>5</div>
  <div class="basel-swatch basel-tooltip  text-only swatch-size-large swatch-disabled"><span class="basel-tooltip-label">5 ½</span>5 ½</div>
  <div class="basel-swatch basel-tooltip  text-only swatch-size-large swatch-disabled"><span class="basel-tooltip-label">6</span>6</div>
  <div class="basel-swatch basel-tooltip  text-only swatch-size-large swatch-disabled"><span class="basel-tooltip-label">6 ½</span>6 ½</div>
  <div class="basel-swatch basel-tooltip  text-only swatch-size-large swatch-disabled"><span class="basel-tooltip-label">7</span>7</div>
  <div class="basel-swatch basel-tooltip  text-only swatch-size-large swatch-disabled"><span class="basel-tooltip-label">7 ½</span>7 ½</div>
  <div class="basel-swatch basel-tooltip  text-only swatch-size-large swatch-disabled"><span class="basel-tooltip-label">8</span>8</div>
  <div class="basel-swatch basel-tooltip  text-only swatch-size-large swatch-disabled"><span class="basel-tooltip-label">8 ½</span>8 ½</div>
  <div class="basel-swatch basel-tooltip  text-only swatch-size-large swatch-disabled"><span class="basel-tooltip-label">9</span>9</div>
  <div class="basel-swatch basel-tooltip  text-only swatch-size-large swatch-disabled"><span class="basel-tooltip-label">10</span>10</div>
  <div class="basel-swatch basel-tooltip  text-only swatch-size-large swatch-disabled"><span class="basel-tooltip-label">11</span>11</div>
  <div class="basel-swatch basel-tooltip  text-only swatch-size-large swatch-disabled"><span class="basel-tooltip-label">12</span>12</div>
</div>