Fbprophet / pystan - python

I am tying to install Fbprophet (python)
I followed all installation instructions (anaconda).
If I try to run Fbprophet in my anaconda prompt it works fine.
However, when I create a project in Visual studio 2017 I get the following error message:
Traceback (most recent call last):
File "C:\Users\dommarch\source\repos\FbProphet\FbProphet\FbProphet.py", line 1, in
import fbprophet
File "C:\Users\dommarch\AppData\Local\Continuum\anaconda2\envs\python36\lib\site-packages\fbprophet__init__.py", line 8, in
from fbprophet.forecaster import Prophet
File "C:\Users\dommarch\AppData\Local\Continuum\anaconda2\envs\python36\lib\site-packages\fbprophet\forecaster.py", line 17, in
import pystan # noqa F401
File "C:\Users\dommarch\AppData\Roaming\Python\Python36\site-packages\pystan__init__.py", line 9, in
from pystan.api import stanc, stan
File "C:\Users\dommarch\AppData\Roaming\Python\Python36\site-packages\pystan\api.py", line 13, in
import pystan._api # stanc wrapper
ImportError: DLL load failed: %1 is not a valid Win32 application.
If anyone has an idea it would be awesome.
Thanks

The version of (fb)prophet, pystan and python are important.
I managed to get it working for this stack:
CentOS: 7
Python: 3.8
GCC: 4.8.5
PyStan: 2.19.1.1
FbProphet: 0.7.1
And for this particular stack, you need GCC++ 2014 compiler, provided by this package:
centos-release-scl devtoolset-8
For Windows, using conda, python 3.8, steps are documented in this article and will summarize below:
Access anaconda using conda command in your command line
Build new virtual environment e.g. time_series, this environment will run in Python 3.8,
conda create -n time_series python=3.8
Access your environment using this command:
conda activate time_series
Install the C++ compiler:
conda install libpython m2w64-toolchain -c msys2
Installation of the dependencies of fbprophet:
conda install numpy cython -c conda-forge
conda install matplotlib scipy pandas -c conda-forge
conda install pystan -c conda-forge
conda install -c anaconda ephem
Install the library that will used for your time series forecasting environment:
pip install scikit-learn
pip install --user pmdarima
conda install -c conda-forge fbprophet
Note: Fbprophet was renamed to Prophet
https://github.com/facebook/prophet/issues/1874
So, you may need to install prophet too:
pip install pystan==2.19.1.1 prophet
or
conda install -c conda-forge prophet

Related

how do I install a specific version of the rdkit library for Python2?

I need to install a version of the rdkit library released prior to 2019, when support for Python 2 was removed. This is needed to work with this library: https://github.com/brain-research/deep-molecular-massspec
I have downloaded the library from the git page, eg. https://github.com/rdkit/rdkit/releases/tag/Release_2018_09_1, and tried using pip to install from that.
sudo pip install rdkit-Release_2018_09_1b1.tar.gz
I get the following error:
Processing ./rdkit-Release_2018_09_1b1.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "", line 1, in
IOError: [Errno 2] No such file or directory: '/tmp/pip-ohIcaj-build/setup.py'
---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-ohIcaj-build
I have tried installing the specific version using pip too:
sudo pip install rdkit==2018.09.01
Which gives:
Collecting rdkit==2018.09.01 Could not find a version that satisfies
the requirement rdkit==2018.09.01 (from versions: ) No matching
distribution found for rdkit==2018.09.01
Can someone tell me how to do this?
#paisanco is correct, attempting to install rdkit with pip will not work. The easiest way to install rdkit is by using Anaconda unless you want to build from source.
If you have Anaconda installed you can create a python 2.7 virtual environment:
conda create --name test-env python=2.7
You can then activate it:
conda activate test-env
And then install the rdkit version you require:
conda install -c rdkit rdkit=2018.09.1
Using Python:
import rdkit
print rdkit.__version__
[Out]: '2018.09.1'
Create a new conda environment with python 2.7.15:
conda create -n py27_rdkit python=2.7.15 ipython
Activate environment (python2.7)
conda activate py27_rdkit
Now in the py27_protac environment, install older version of rdkit that won't gripe about python2.7:
conda install -c conda-forge rdkit rdkit=2018.09.1
The conda install command in answer above: 'conda install -c rdkit rdkit=2018.09.1' failed due numerous conflicts.
The problem is what you downloaded, according to that site, is a tar archive containing the source code for that library, not a pip package.
So attempting to install it using pip will not work.
The RDKit project home page gives other options for installing 1) from within an Anaconda conda virtual environment 2) from the source code (what you downloaded) for Windows, Linux, and Mac.
Those instructions are at RDKit installation instructions
conda create -n my_env python=3.7
conda activate my_env
conda install numpy matplotlib
conda install cmake cairo pillow eigen pkg-config
conda install boost-cpp boost py-boost
and download rdkit package https://anaconda.org/rdkit/rdkit/files
# finally
conda install rdkit-2020.09.1b1.0-py37hd50e099_1.tar.bz2

Installing fbprophet Python on Windows 10

My build keeps failing on windows 10 for installing fbprophet in anaconda with the following message:
ERROR conda.core.link:_execute(502): An error occurred while installing package 'conda-forge::automat-0.7.0-py_1'.
CondaError: Cannot link a source that does not exist. C:\Users\bharat.c.ruparel\AppData\Local\Continuum\anaconda3\Scripts\conda.exe
the command that is given is:
conda install -c conda-forge fbprophet
Has anyone successfully installed fbprophet on Windows 10? If yes, then please give the steps.
Thanks.
I tried pip install as well but no luck. I have a Mac and managed to install fbprophet on it without any issues.
First install Anaconda or miniconda in your Windows machine and add conda python path to env variable as default python.
Open your command prompt and run following commands.
Create a conda virtual environment (optional)
conda create -n v-env python=3.7
activate v-env
Install c++ complier
conda install libpython m2w64-toolchain -c msys2
libpython will automatically create and setup distutils.cfg file for you in PYTHONPATH\Lib\distutils, but if that is failed use the following instructions to setup it manually
[OPTIONAL]
create distutils.cfg with text editor (e.g. notepad, notepad++) and add the following lines to that file.
[build]
compiler=mingw32
Install dependencies
conda install numpy cython -c conda-forge
conda install matplotlib scipy pandas -c conda-forge
Install PyStan
pip install pystan
or
conda install pystan -c conda-forge
Install Ephem
conda install -c anaconda ephem
Install fbprophet
pip install fbprophet
or
conda install -c conda-forge fbprophet
I also faced installing facebook prophet issue in windows 10 without conda.
But,we can solve it.
First, uninstall any pystan, fbprophet.
Then follow the steps below,
python.exe -m pip install pystan==2.17.1.0
python.exe -m pip install fbprophet==0.6
python.exe -m pip install --upgrade fbprophet
Thanks,
tsj
Updated: 28 July 2022
As of v1.0, the package name on PyPI is "prophet"; prior to v1.0 it was "fbprophet". fbprophet is now just prophet. A few additional considerations:
From v0.6 onwards, Python 2 is no longer supported.
As of v1.1, the minimum supported Python version is 3.7.
Below one will find how to
Install with PyPI
Install with Anaconda
Install the Development version
1. Istallation in Python using PyPI
Prophet is on PyPI, so one can use pip to install it.
python -m pip install prophet
2. Installation in Python using Anaconda
One might have to access Anaconda Prompt for the environment that one is working with as admin:
And run
conda-forge: conda install -c conda-forge prophet
Or
conda install -c conda-forge prophet -y
3. Development version
To get the latest code changes as they are merged, one can clone this repo and build from source manually. This is not guaranteed to be stable.
git clone https://github.com/facebook/prophet.git
cd prophet/python
python -m pip install -r requirements.txt
python setup.py develop
By default, Prophet will use a fixed version of cmdstan (downloading and installing it if necessary) to compile the model executables. If this is undesired and one would like to use one's existing cmdstan installation, one can set the environment variable PROPHET_REPACKAGE_CMDSTAN to False:
export PROPHET_REPACKAGE_CMDSTAN=False;
Sources
https://facebook.github.io/prophet/docs/installation.html
https://github.com/facebook/prophet
I've had the same problem. But it works after I follow this steps:
On Prompt install Ephem:
conda install -c anaconda ephem
Install Pystan:
conda install -c conda-forge pystan
Finally install Fbprophet
conda install -c conda-forge fbprophet
Latest installation code for 2021:
pip install pystan==2.19.1.1, then pip install prophet
Also, reboot your jupyter notebook after installation
Install without Conda, Win 10, Python 3.8.8 64 bit.
pip3 install Cython
Then install:
Reboot your maching
Install
pip3 install pystan==2.17.1.0
pip3 install fbprophet
Here's my solution. I have not use conda-forge before, so reading up on this article helps.
Making sure that conda is ≥4.9
conda --version
add conda forge channel
conda config --add channels conda-forge
conda --set channel_priority strict
install gcc
conda install gcc
install prophet
conda install -c conda-forge prophet
I used the prophet documentation here
I faced the same issue and my solution was to:-
Create a new environment with Python3.5
conda create -n pht python=3.5 anaconda
Install Prophet using the command.
conda install -c conda-forge fbprophet
I didn't install 'gcc' although this was advised before installing Prophet.
I am using Python 3.8.5 and conda 4.10.1 on a Windows 10 machine.
I was able to install prophet in Anaconda 2.0.1 using command prompt (not as admin), using: conda install -c conda-forge fbprophet
It took some time for it to figure out the details, as you can see from the prompts below, but finally it was able to install the package.
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: done

How to use anaconda packages in python environment on a linux server?

I have installed anaconda , and use conda install -c anaconda tensorflow-gpu to install tensorflow .
I activate tensorflow by using source activate tensorflow sucessfully, but I find that I can't use other anaconda packages , such as pandas .
How to use tensorflow and anaconda packages sucessfully?
Here is my operations and the versions of anaconda and tensorflow.
anaconda version:
# Name Version Build Channel
anaconda 5.3.0 py37_0
tensorflow version:
(base) anonym2#amax:/data/anonym2/code$ source activate tensorflow
(tensorflow) anonym2#amax:/data/anonym2/code$ python -c 'import tensorflow as tf; print(tf.__version__)'
1.5.0
import pandas in tensorflow environment:
(tensorflow) anonym2#amax:/data/anonym2/code$ import pandas
import: unable to open X server `localhost:10.0' # error/import.c/ImportImageCommand/364.
(tensorflow) anonym2#amax:/data/anonym2/code$ python test.py
Traceback (most recent call last):
File "test.py", line 9, in <module>
import pandas as pd
ModuleNotFoundError: No module named 'pandas'
Please read conda usage first.
conda install -n your_env_name pandas may solve import pandas error, and replace your_env_name into your own environment name.
You have to install packages as many as you need. To avoid this, you could create an environment with a specific version of anaconda python before installing tensorflow by conda create -n your_env_name python=3.7 anaconda. The python version can be changed as you want.

Prophet / fbprophet package in Python

Can someone explain how to install Prophet on Python3?
I tried pip install fbprophet but it did not work.
Tried to do this in the notebook after importing pandas and sklearn and got another error:
import pandas as pd
import sklearn as sk
from fbprophet import Prophet
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-4-f503e9c6cf11> in <module>()
----> 1 from fbprophet import Prophet
ModuleNotFoundError: No module named 'fbprophet'
First you have to Install c++ compiler, you can install c++ compiler with below command -
conda install libpython m2w64-toolchain -c msys2
Once c++ compiler installed you have to install pystan, to install pystan you can use below command
pip install pystan
Finally, now we are ready to install facebook prophet -
pip install fbprophet
Hope this is helpful..
For more details follow this link -
https://facebook.github.io/prophet/docs/installation.html
Easiest way is to install fbprophet :
conda install -c conda-forge fbprophet
This will download all the needed packages first.
Then ->
conda install -c conda-forge/label/cf201901 fbprophet
Try installing fbprophet
pip install fbprophet
Or
pip3 install fbprophet
I had relatively similar problem, but my error was it couldn't import pystan which in installed using pip install pystan. so the problem was fbprophet doesn't support latest version of pystan so uninstall previous one and install older version of pystan.
pip install pystan==2.19.1.1
pip install fbprophet
https://facebook.github.io/prophet/docs/installation.html
On Windows it's easier using anaconda or miniconda, just give
conda install pystan
and it will install all the needed dependencies, included the c++ compiler, then
pip install fbprophet
in Linux systems, for example, ubuntu, a simple
pip install pystan
pip install fbprophet
should work, without installing anaconda/miniconda
!pip install pystan==2.19.1.1 fbprophet ##### i was trying to install fbprophet==0.7.1 but in the presence of cmdstanpy==0.9.5 it was unable to build the wheel for fbprophet.
after executing the above command for installing pystan==2.19.1.1 collectively with fbprophet successfully installed cmdstanpy-0.9.5 fbprophet-0.7.1 note that there is no version specified for fbprophet in the command and pystan is specified with version 2.19.1.1 to avoid dependency conflicts.
This worked for me. pip3 was a must!
pip3 install pystan
pip3 install fbprophet

Install gdal using conda?

I used
conda install gdal
to install the GDAL packages. But I had the following error when importing the packages.
>>> from osgeo import gdal
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/danqing0703/anaconda/lib/python2.7/site-packages/osgeo/__init__.py", line 21, in <module>
_gdal = swig_import_helper()
File "/Users/danqing0703/anaconda/lib/python2.7/site-packages/osgeo/__init__.py", line 17, in swig_import_helper
_mod = imp.load_module('_gdal', fp, pathname, description)
ImportError: dlopen(/Users/danqing0703/anaconda/lib/python2.7/site-packages/osgeo/_gdal.so, 2): Library not loaded: libgdal.20.dylib
Referenced from: /Users/danqing0703/anaconda/lib/python2.7/site-packages/osgeo/_gdal.so
Reason: image not found
>>> from osgeo import ogr
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/danqing0703/anaconda/lib/python2.7/site-packages/osgeo/__init__.py", line 21, in <module>
_gdal = swig_import_helper()
File "/Users/danqing0703/anaconda/lib/python2.7/site-packages/osgeo/__init__.py", line 17, in swig_import_helper
_mod = imp.load_module('_gdal', fp, pathname, description)
ImportError: dlopen(/Users/danqing0703/anaconda/lib/python2.7/site-packages/osgeo/_gdal.so, 2): Library not loaded: libgdal.20.dylib
Referenced from: /Users/danqing0703/anaconda/lib/python2.7/site-packages/osgeo/_gdal.so
Reason: image not found
What should I do to have GDAL imported in Python?
For windows users (as of December 2015):
conda install gdal
conda upgrade numpy
Installing gdal will downgrade numpy, so then upgrade it back up.
I recently had occasion to use windows for a change and I was pleasantly surprised that gdal "works" easily now.
Windows+python+gis people worldwide should be celebrating this. (that gdal-python goes in easily on windows...not that windows is one step closer to linux ;) )
I just made the mistake of executing the previously proposed command in the base environment of Conda:
conda install -c conda-forge gdal
This took ages to "solve environment" and, in the end, found numerous conflicts which halted the installation.
Given that, I instead created a separate environment with:
conda create -n gdal python=3.8
And activated it with:
conda activate gdal
And then executed the first command (as well as all others listed in the documentation). This worked fast and without any errors.
you can also use the channel conda-forge
conda install -c conda-forge gdal
as suggested on the anaconda website.
I used
conda install -c conda-forge gdal
On a Fedora 30 machine and it lead me down a path of library conflict hell!
conda install gdal
worked on my first try
The following works reliably for me Ubuntu 20.04:
conda update conda
sudo apt-get install libgdal-dev gdal-bin
export CPLUS_INCLUDE_PATH=/usr/include/gdal
export C_INCLUDE_PATH=/usr/include/gdal
# check gdal version with
gdal-config --version
echo '
name: raster-pipeline
channels:
- defaults
dependencies:
- python=3.7.*
- cython
- numpy
- ipython
- libspatialindex
- libgdal=USE_GDAL_VERSION
- gdal=USE_GDAL_VERSION
- pip
- pip:
- numpy>=1.18.5
- GDAL==USE_GDAL_VERSION
- pyproj>=2.6.1.post1
- rasterio>=1.1.5
' > raster_pipeline.yml
conda env create -f raster_pipeline.yml -v
conda activate raster_pipeline
python -c "from osgeo import gdal"
conda deactivate
This works for me
> CONDA_SUBDIR=osx-64 conda create -n my_env python=3.7
> conda activate my_env
> conda env config vars set CONDA_SUBDIR=osx-64
> conda install gdal
Now use,
> python3
> from osgeo import gdal
I had the same problem, and after several days trying different solutions, I found the problem in conflict between Anaconda version and python version! if you have both Python and Anaconda on your system, then uninstall the python and use anaconda prompt to run this:
pip install gdal
This worked for me . Hope it is useful to someone . I am using Ubuntu 20.04: It install osgeo also with gdal
Step 1 : conda install -c conda-forge gdal
If there is still some error then
Step 2 : conda config --set channel_priority strict”
Step 3 : conda update gdal
For existing conda-env, I did do like below on Ubuntu 20.04:
conda update conda
sudo apt-get install libgdal-dev gdal-bin
$export CPLUS_INCLUDE_PATH=/usr/include/gdal
$export C_INCLUDE_PATH=/usr/include/gdal
$gdal-config --version
gdal3.0.4
$whereis pip
/usr/local/anaconda3/bin/pip # anaconda's pip
$/usr/local/anaconda3/bin/pip install setuptools==57.4.0
$/usr/local/anaconda3/bin/pip install gdal==3.0.4

Categories

Resources