用R

时间:2017-08-18 13:02:43

标签: python r tensorflow rstudio

我正在尝试在Rstudio中安装tensorflow,当我运行install_tensorflow()时,我得到了

Error: Prerequisites for installing TensorFlow not available.

Execute the following at a terminal to install the prerequisites:

$ sudo pip install --upgrade virtualenv

但已安装virtualenv

我对python没有太多了解。

我正在使用OSX

which python输出

`/home/name/.pyenv/shims/python`

但是当我去python控制台时,我得到了

Python 2.7.10 (default, Dec  3 2015, 00:46:36) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.1.76)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'/home/name/.pyenv/versions/2.7.10/bin/python'
system("python --version")输出中的

Rstudio

Python 2.7.10

所以我试图加入.Rprofile这个

Sys.setenv(PATH = paste("/home/name/.pyenv/versions/2.7.10/bin/python", Sys.getenv("PATH"), sep=":"))

或者

Sys.setenv(PATH = paste("/home/name/.pyenv/shims/python", Sys.getenv("PATH"), sep=":"))

此外,我发现确实安装了tensorflow个包

/home/name/.pyenv/versions/2.7.10/lib/python2.7/site-packages

有人有想法吗?

更新:

由于python tensorflow软件包已安装在/home/name/.pyenv/somepath/下的系统中,我试图在RStudio内直接运行一些tensorflow函数,我得到了这个

Error: Installation of TensorFlow not found.

Python environments searched for 'tensorflow' package:
 /usr/bin/python

You can install TensorFlow using the install_tensorflow() function.

知道在Sys.getenv()中运行RStudio会提供正确的路径

路径/home/name/.pyenv/versions/2.7.10/bin/python:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/texbin:/opt/local/bin

更新2

现在,我想我开始找到问题所在。我强制RStudio使用我在运行python

时获得的sys.executable '/home/name/.pyenv/versions/2.7.10/bin/python'版本

所以use_python("/home/name/.pyenv/versions/2.7.10/bin/python")

现在,当我运行一些tensorflow函数时,我得到了

错误:找不到Python模块tensorflow。

检测到Python配置:

python:         /usr/bin/python
libpython:      /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/config/libpython2.7.dylib
pythonhome:     /System/Library/Frameworks/Python.framework/Versions/2.7:/System/Library/Frameworks/Python.framework/Versions/2.7
version:        2.7.10 (default, Oct 23 2015, 19:19:21)  [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)]
numpy:          /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy
numpy_version:  1.8.1
tensorflow:     [NOT FOUND]

似乎Rstudio没有考虑我希望它使用的版本

解决方案:要找到问题的来源以及如何解决问题,请获取here

0 个答案:

没有答案