简体   繁体   中英

Fbprophet installation error - failed building wheel for fbprophet

I am trying to install fbprophet for Python using Pip install, but failing. I have already installed Pystan.

Can I import it using Anaconda Navigator?

Can someone please help.

Failed building wheel for fbprophet

Running setup.py clean for fbprophet
Failed to build fbprophet
Installing collected packages: fbprophet
  Running setup.py install for fbprophet ... error
    Complete output from command C:\ProgramData\Anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\SJ-Admin\\AppData\\Local\\Temp\\pip-build-bsm4sxla\\fbprophet\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\SJ-Admin\AppData\Local\Temp\pip-kvck8fw1-record\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build\lib
    creating build\lib\fbprophet
    creating build\lib\fbprophet\stan_models
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\SJ-Admin\AppData\Local\Temp\pip-build-bsm4sxla\fbprophet\setup.py", line 126, in <module>
        """
      File "C:\ProgramData\Anaconda3\lib\site-packages\setuptools\__init__.py", line 129, in setup
        return distutils.core.setup(**attrs)
      File "C:\ProgramData\Anaconda3\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "C:\ProgramData\Anaconda3\lib\distutils\dist.py", line 955, in run_commands
        self.run_command(cmd)
      File "C:\ProgramData\Anaconda3\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "C:\ProgramData\Anaconda3\lib\site-packages\setuptools\command\install.py", line 61, in run
        return orig.install.run(self)
      File "C:\ProgramData\Anaconda3\lib\distutils\command\install.py", line 545, in run
        self.run_command('build')
      File "C:\ProgramData\Anaconda3\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:\ProgramData\Anaconda3\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "C:\ProgramData\Anaconda3\lib\distutils\command\build.py", line 135, in run
        self.run_command(cmd_name)
      File "C:\ProgramData\Anaconda3\lib\distutils\cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "C:\ProgramData\Anaconda3\lib\distutils\dist.py", line 974, in run_command
        cmd_obj.run()
      File "C:\Users\SJ-Admin\AppData\Local\Temp\pip-build-bsm4sxla\fbprophet\setup.py", line 46, in run
        build_stan_models(target_dir)
      File "C:\Users\SJ-Admin\AppData\Local\Temp\pip-build-bsm4sxla\fbprophet\setup.py", line 28, in build_stan_models
        from pystan import StanModel
    ImportError: cannot import name 'StanModel'

Fundamental step: Switch to your environment in your Anaconda prompt: conda activate name-of-your-python-enviornment

Then the following steps shall work:

  1. On Prompt install Ephem:

     conda install -c anaconda ephem
  2. Install Pystan:

     conda install -c conda-forge pystan
  3. Finally install Fbprophet:

     conda install -c conda-forge fbprophet
  4. If exists error from holidays package

    pip install holidays==0.9.12

Reference: https://github.com/facebook/prophet/issues/892

Reference for Holiday package error: https://github.com/facebook/prophet/issues/1300

I could install fbprophet using conda install -c conda-forge fbprophet. This was failing too due to permission issue My folder had 'read-only' permissions. I modified it to read-write. Then reran the command and was able to install fbprophet

So after I did

conda install -c conda-forge fbprophet

I got at the end:

EnvironmentNotWritableError: The current user does not have write permissions to the target environment.
  environment location: C:\ProgramData\Anaconda3

ProgramData is system folder, so changed rw permissions(took few minutes), and I also did this for C:\\Program Files\\Python37 path with Lib folder.

Use offline package installer: this works with Python 3.8. and Python 3.9.x

pip install localpip 
localpip install fbprophet

For this stack:

  • CentOS: 7
  • Python: 3.8
  • GCC: 4.8.5
  • PyStan: 2.19.1.1
  • FbProphet: 0.7.1

You need these packages:

  • centos-release-scl devtoolset-8

Enable SCL devtoolset-8

source /opt/rh/devtoolset-8/enable
  • rh-python38-python rh-python38-python-devel
  • pip install pystan==2.19.1.1

Docker image with HTTPD MOD_WSGI and FBPROPHET...

FROM centos:7

EXPOSE 80

# Install Apache
RUN yum -y update
RUN yum -y install centos-release-scl
RUN yum -y install httpd httpd-tools rh-python38-python-mod_wsgi.x86_64 devtoolset-8-gcc devtoolset-8-gcc-c++ rh-python38-python rh-python38-python-devel

# Copy the wsgi module to Apache HTTP Server modules folder
RUN cp /opt/rh/httpd24/root/usr/lib64/httpd/modules/mod_rh-python38-wsgi.so /lib64/httpd/modules/mod_wsgi.so

ENV PATH="/opt/rh/rh-python38/root/usr/bin:/opt/rh/rh-python38/root/usr/local/bin:${PATH}"

WORKDIR /
COPY ROOT .

WORKDIR /opt/rh/rh-python38/root
RUN ./usr/bin/python3 /etc/get-pip.py

RUN chmod +x /usr/local/bin/install-fb.sh && /usr/local/bin/install-fb.sh
RUN pip install -r /etc/requirements.txt

# Start Apache
CMD ["/usr/sbin/httpd","-D","FOREGROUND"]

The script install-fb.sh contains this code:

$ cat ROOT/usr/local/bin/install-fb.sh
#!/bin/bash
source /opt/rh/devtoolset-8/enable
pip install pystan==2.19.1.1 fbprophet==0.7.1

The reason to put it in its own script is the SCL enable line, to avoid the gcc not found error.

I hope this helps, getting all these software packages running together is not a piece of cake:)

With the following environment

OSX: Big Sur 11.6

python: python:3.7-slim

$ pip install pystan==2.19
$ pip install fbprophet

This worked for me:

pip install prophet
pip install fbprophet

Docker Image: python 3.8-slim

This worked for me:

pip install pystan==2.19.1.1
pip install fbprophet

macOS Big Sur 11.5.2

python 3.7

This worked for me:

pip install pystan==2.19.1.1
sudo pip install fbprophet==0.7.1

FB prophet documentation recommends using conda for windows users as the easiest way for installing prophet. In my case, the following solved the problem (win10):

conda install -c conda-forge fbprophet -y

Installing collected packages: pystan Attempting uninstall: pystan Found existing installation: pystan 3.3.0 Uninstalling pystan-3.3.0: Successfully uninstalled pystan-3.3.0 Successfully installed pystan-2.19.1.1

Why fbprophet is getting error while.pip install fbprophet in googlecolab eventhough pystan 3.3?0 was installed in googlecolab. fbprophet is working only when pystan 2.19.1?1 or some other versions? is there any connection between pystan and fbprophet?

  1. Create a virtual environment using:

conda create --name myenv

  1. Activate the environment using:

conda activate myenv

  1. Install ephem using:

conda install -c anaconda ephem

  1. Install pystan using

conda install -c conda-forge pystan

  1. Install the fbrprophet using

conda install -c conda-forge fbprophet

  1. At the end install holidays :

pip install holidays==0.9.12

  1. If it still doesn't work try this at last:

conda install psycopg2

After a lot of research, I found the solution for installing fbprophet on windows 10.

Step 1: Check the kernel in jupyter. Locate the folder \\jupyter\\kernels\\python3 and check the python exe location used by the kernel. Mine was pointing to - Programs\\Python\\Python37\\python.exe open CMD prompt and go to above dir.

I am skipping pystan installation as I already installed pystan using pip command.

Step 2 : Download the file "Twisted-20.3.0-cp37-cp37m-win_amd64.whl" from https://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted

python -m pip install /Twisted-20.3.0-cp37-cp37m-win_amd64.whl

Step 3 : pip install fbprophet

Installing collected packages: fbprophet Successfully installed fbprophet-0.6

Step 4 : python

import fbprophet

fbprophet. version

'0.6'

fbprophet has been renamed by prophet hence 1st install pip install pystan==2.19.1.1 then do python -m pip install prophet this will work! then to import do from prophet import Prophet

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM