windows下安装fbprophet(已解决visual studio 2014报错问题)

本人使用windows10 64位,python3.5.2,anaconda3.5.3,安装这个机车的函数包,累计耗时快10个小时,总是会有各种错误。最后终于成功[]~( ̄▽ ̄)~*

首先需要保证安装中共已安装visual studio 2015中的C++模块,然后要保证python中已安装以下版本的函数包(使用pip安装即可):

Cython>=0.22
pystan>=2.14
numpy>=1.10.0
pandas>=0.20.1
matplotlib>=2.0.0

接下来安装fbprophet,我是在官网中下载fbprophet的tar.gz包用python setup.py install安装的,安装的时候可能会出现问题,我的是出现了以下问题:

fbprophet error: command 'c:\\program files (x86)\\microsoft visual studio 14.0\\vc\\bin\\x86_amd64\\link.exe' failed with exit status 1120

而且在使用pytsan的时候也会出现上面的error,然后我就重装pystan,重装visual studio 2015,但是根本没用。通过各种百度,翻墙搜索,发现可能是C++编译器没装好,找到了如下解决办法(我是在anaconda的python3.5.2环境中进行安装的):

打开anaconda prompt,进入要要安装的python环境中(python35即是我的python3.5.2环境):

conda activate python35

然后就开始安装MingW-w64编译器工具链:

conda install libpython m2w64-toolchain -c msys2

待一段时间的安装过后,在anaconda prompt中打开python,找到distutils路径:

python
>>> import distutils
>>> print(distutils.__file__)

然后用文本编辑器(记事本)创建distutils.cfg文件,添加:

[build]
compiler=mingw32

若已存在该文件,则保证文件中内容是上述内容即可。

接下来,对pystan进行测试(已用pip安装pystan),可打开python输入以下代码:

>>> import pystan
>>> model_code = 'parameters {real y;} model {y ~ normal(0,1);}'
>>> model = pystan.StanModel(model_code=model_code)
>>> y = model.sampling().extract()['y']
>>> y.mean()  # with luck the result will be near 0

若没有报错,则说明pystan安装成功。(可能会有一段有关Cython的报错,说的大概是Cython是基于python2安装的,但是现在的环境是python3,这个报错是不会影响代码的运行的)

接下来就可以安装fbprophet了,在官网或者github中下载fbprophet的压缩包,然后解压缩,用anaconda prompt进入这个文件夹,用python安装即可,代码如下(需要根据你的解压缩路径进行修改):

conda activate python35 #进入想要安装的python环境
cd C:/Users/26869/Desktop/prophet-master/python #进入解压的文件夹(这个是github上下载的文件夹,官网上下载的自行修改即可)
python setup.py install #安装

然后理论上就大功告成啦!

猜你喜欢

转载自blog.csdn.net/lixuanming/article/details/84292253
今日推荐