写在前面
之前在window11上,安装了一下午,不是C++版本不行,就是这个那个不通过,主要是Pystan运行不起来就很气,fbprophet本身就需要依赖这个包,然后MSVC不支持,裂开。尝试了很多次,碰到最后的错误是个这
 直接把我劝退!
所以扭头就奔服务器去了!
开始安装
首先需要创建一个conda环境,并且python版本 3.7, 这个可以参考已有的博客,我的取名是py3.7。
 下面是安装各种包,其实可以不着急,先更新一下pip。
 最好在这之前更新一下镜像源,我用的是清华的:
vim ~/.condarc
show_channel_urls: true
channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
 
然后更新pip:
(py3.7) ***@scs4450:~/CTT$ python -m pip install --upgrade pip
Requirement already satisfied: pip in /home/jiangyun/anaconda3/envs/py3.7/lib/python3.7/site-packages (21.3.1)
Collecting pip
  Downloading pip-23.1.1-py3-none-any.whl (2.1 MB)
     |████████████████████████████████| 2.1 MB 1.3 MB/s            
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 21.3.1
    Uninstalling pip-21.3.1:
      Successfully uninstalled pip-21.3.1
Successfully installed pip-23.1.1
 
然后,直接安装pystan,按照以下命令
(py3.7) ***@scs4450:~/CTT$ pip install pystan~=2.14
Collecting pystan~=2.14
  Downloading pystan-2.19.1.1-cp37-cp37m-manylinux1_x86_64.whl (67.3 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 67.3/67.3 MB 7.5 MB/s eta 0:00:00
Collecting Cython!=0.25.1,>=0.22 (from pystan~=2.14)
  Downloading Cython-0.29.34-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (1.9 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.9/1.9 MB 18.7 MB/s eta 0:00:00
Requirement already satisfied: numpy>=1.7 in /home/jiangyun/anaconda3/envs/py3.7/lib/python3.7/site-packages (from pystan~=2.14) (1.21.4)
Installing collected packages: Cython, pystan
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
pycocotools 2.0.2 requires matplotlib>=2.1.0, which is not installed.
 
之前看到有人说使用官方下载的 pystan,这里贴一下,可能会遇到类似的问题:
(py3.7) ***@scs4450:~/CTT$ pip install pystan-3.7.0-py3-none-any.whl 
Processing ./pystan-3.7.0-py3-none-any.whl
Collecting pysimdjson<6.0.0,>=5.0.2
  Downloading pysimdjson-5.0.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.8 MB)
     |████████████████████████████████| 1.8 MB 5.5 MB/s            
Requirement already satisfied: numpy<2.0,>=1.19 in /home/jiangyun/anaconda3/envs/py3.7/lib/python3.7/site-packages (from pystan==3.7.0) (1.21.4)
Collecting aiohttp<4.0,>=3.6
  Using cached aiohttp-3.8.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (948 kB)
ERROR: Could not find a version that satisfies the requirement httpstan<4.11,>=4.10 (from pystan) (from versions: 0.6.0, 0.6.1, 0.7.0, 0.7.1, 0.7.2, 0.7.5, 0.7.6, 0.8.0, 0.10.1, 1.0.0, 1.1.0, 1.1.1, 1.1.2, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.1.0, 2.2.0, 2.3.0, 4.0.0, 4.1.0, 4.2.1, 4.3.0, 4.3.1, 4.3.2, 4.4.0, 4.4.1, 4.4.2)
ERROR: No matching distribution found for httpstan<4.11,>=4.10
 
这个.whl文件是在PyPI下载的,应该是没有问题,但是直接装会遇到一点奇奇怪怪的错误。
好了,pystan的安装是否成功还得验证一下:
(py3.7) ***@scs4450:~/CTT$ python
Python 3.7.12 | packaged by conda-forge | (default, Oct 26 2021, 06:08:21) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pystan
>>> model_code = 'parameters {real y;} model {y ~ normal(0,1);}'
>>> model = pystan.StanModel(model_code=model_code)
INFO:pystan:COMPILING THE C++ CODE FOR MODEL anon_model_5944b02c79788fa0db5b3a93728ca2bf NOW.
>>> y=model.sampling().extract()['y']
Gradient evaluation took 1.3e-05 seconds
1000 transitions using 10 leapfrog steps per transition would take 0.13 seconds.
Gradient evaluation took 1.1e-05 seconds
Adjust your expectations accordingly!
1000 transitions using 10 leapfrog steps per transition would take 0.11 seconds.
Adjust your expectations accordingly!
Gradient evaluation took 1.1e-05 seconds
1000 transitions using 10 leapfrog steps per transition would take 0.11 seconds.
Adjust your expectations accordingly!
Iteration:    1 / 2000 [  0%]  (Warmup)
Iteration:    1 / 2000 [  0%]  (Warmup)
Gradient evaluation took 1.1e-05 seconds
1000 transitions using 10 leapfrog steps per transition would take 0.11 seconds.
Iteration:    1 / 2000 [  0%]  (Warmup)
Adjust your expectations accordingly!
Iteration:    1 / 2000 [  0%]  (Warmup)
Iteration:  200 / 2000 [ 10%]  (Warmup)
Iteration:  200 / 2000 [ 10%]  (Warmup)
Iteration:  200 / 2000 [ 10%]  (Warmup)
Iteration:  200 / 2000 [ 10%]  (Warmup)
Iteration:  400 / 2000 [ 20%]  (Warmup)
Iteration:  400 / 2000 [ 20%]  (Warmup)
Iteration:  400 / 2000 [ 20%]  (Warmup)
Iteration:  400 / 2000 [ 20%]  (Warmup)
Iteration:  600 / 2000 [ 30%]  (Warmup)
Iteration:  600 / 2000 [ 30%]  (Warmup)
Iteration:  600 / 2000 [ 30%]  (Warmup)
Iteration:  600 / 2000 [ 30%]  (Warmup)
Iteration:  800 / 2000 [ 40%]  (Warmup)
Iteration:  800 / 2000 [ 40%]  (Warmup)
Iteration:  800 / 2000 [ 40%]  (Warmup)
Iteration:  800 / 2000 [ 40%]  (Warmup)
Iteration: 1000 / 2000 [ 50%]  (Warmup)
Iteration: 1001 / 2000 [ 50%]  (Sampling)
Iteration: 1000 / 2000 [ 50%]  (Warmup)
Iteration: 1001 / 2000 [ 50%]  (Sampling)
Iteration: 1000 / 2000 [ 50%]  (Warmup)
Iteration: 1001 / 2000 [ 50%]  (Sampling)
Iteration: 1000 / 2000 [ 50%]  (Warmup)
Iteration: 1001 / 2000 [ 50%]  (Sampling)
Iteration: 1200 / 2000 [ 60%]  (Sampling)
Iteration: 1200 / 2000 [ 60%]  (Sampling)
Iteration: 1200 / 2000 [ 60%]  (Sampling)
Iteration: 1200 / 2000 [ 60%]  (Sampling)
Iteration: 1400 / 2000 [ 70%]  (Sampling)
Iteration: 1400 / 2000 [ 70%]  (Sampling)
Iteration: 1400 / 2000 [ 70%]  (Sampling)
Iteration: 1400 / 2000 [ 70%]  (Sampling)
Iteration: 1600 / 2000 [ 80%]  (Sampling)
Iteration: 1600 / 2000 [ 80%]  (Sampling)
Iteration: 1600 / 2000 [ 80%]  (Sampling)
Iteration: 1600 / 2000 [ 80%]  (Sampling)
Iteration: 1800 / 2000 [ 90%]  (Sampling)
Iteration: 1800 / 2000 [ 90%]  (Sampling)
Iteration: 1800 / 2000 [ 90%]  (Sampling)
Iteration: 1800 / 2000 [ 90%]  (Sampling)
Iteration: 2000 / 2000 [100%]  (Sampling)
 Elapsed Time: 0.01824 seconds (Warm-up)
               0.014611 seconds (Sampling)
               0.032851 seconds (Total)
Iteration: 2000 / 2000 [100%]  (Sampling)
 Elapsed Time: 0.018225 seconds (Warm-up)
               0.015881 seconds (Sampling)
               0.034106 seconds (Total)
Iteration: 2000 / 2000 [100%]  (Sampling)
 Elapsed Time: 0.018679 seconds (Warm-up)
               0.016259 seconds (Sampling)
               0.034938 seconds (Total)
Iteration: 2000 / 2000 [100%]  (Sampling)
 Elapsed Time: 0.01865 seconds (Warm-up)
               0.016527 seconds (Sampling)
               0.035177 seconds (Total)
>>> y.mean()
-0.027691342060660575
>>> 
 
一步一步运行,步步惊心,最后输出是这个,就ok!!这是具有里程碑意义的!
后面就顺畅多了:
pip install fbprophet
 

到了这一步,那么按照提示,完成所有的包的安装
conda install pandas
conda install convertdate
conda install lunarcalendar
conda install holidays
 

 最后胜利截图!
 
 这个包确实对环境比较苛刻,安装好了心情爽,如果有用的话就给我点个赞吧!!
















![P1045 [NOIP2003 普及组] 麦森数](https://img-blog.csdnimg.cn/img_convert/db0982748b792a85823a9de3033031f4.png)


