rpy2 安装失败 Microsoft Visual C++ 14.0 is required

安装代码

pip install rpy2

安装报错

显示C++ 14.0 required

copying .\rpy\ipython\tests\__init__.py -> build\lib.win-amd64-3.6\rpy2\ipython\tests
    running build_clib
    building 'r_utils' library
    error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/

解决方法

下载地址: https://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted
我的python版本是:

  • windows10
  • 3.6
  • 64位

我下载的版本为:
rpy2 安装失败  Microsoft Visual C++ 14.0 is required

使用pip install 安装whl文件

首先将下载文件放到当前文件夹下, 然后运行下面命令:
代码

pip install rpy2-2.9.4-cp36-cp36m-win_amd64.whl

结果

$ pip install rpy2-2.9.4-cp36-cp36m-win_amd64.whl
Processing d:\python-ex\rpy2-2.9.4-cp36-cp36m-win_amd64.whl
Requirement already satisfied: jinja2 in c:\users\dengfei\anaconda3\lib\site-packages (from rpy2==2.9.4) (2.10)
Requirement already satisfied: six in c:\users\dengfei\anaconda3\lib\site-packages (from rpy2==2.9.4) (1.11.0)
Requirement already satisfied: MarkupSafe>=0.23 in c:\users\dengfei\anaconda3\lib\site-packages (from jinja2->rpy2==2.9.4) (1.0)
Installing collected packages: rpy2
Successfully installed rpy2-2.9.4

测试

# Example 1
import rpy2.robjects as robjects
pi = robjects.r('pi')
pi[0]

结果

>>> import rpy2.robjects as robjects
>>> pi = robjects.r('pi')
>>> pi[0]
3.141592653589793

搞定.

上一篇:HTTP协议状态码的含义


下一篇:controller层方法上@pathvariable注解中required=false作用失效