fbprophet installation in conda env failed - python

I want to install the package fbprophet (it may now also be known as prophet). I tried importing both like so (not all at once):
import fbprophet
import prophet
from fbprophet import Prophet
from prophet import Prophet
Error I receive is as follows:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_5908/2493871459.py in <module>
----> 1 from prophet import Prophet
ModuleNotFoundError: No module named 'prophet'
I have already gone through all the other questions asking the same problem, yet those solutions didn't work for me. I also tried changing python version to 3.7 when installing it in a new env for testing purposes.
installing prophet in jupyter nb
No module named 'fbprophet'?
Prophet / fbprophet package in Python
some code solution for installation

My advice is to create a fresh conda environment for prophet. You will avoid conflicts and let conda retrieve without any other constraints the required dependencies. Here is how to do it as per the doc.
# create a new env called prophet
# with no other spec than prop
conda create -c conda-forge -n prophet prophet
Use the env.
# activate the env
conda activate prophet
# test
python -c "import prophet; print(prophet.__version__)"
# Importing plotly failed. Interactive plots will not work.
# 1.0
Register it as a Jupyter Kernel as per the doc
# install ipykernl
conda install ipykernel
# register it
python -m ipykernel install --user --name prophet --display-name "Prophet"

Related

ModuleNotFoundError: No module named 'pymc3'

I'm trying to import PyMC3 library in Jupyter Notebook's Python 3 kernel. I've already installed pymc3 initials in Anaconda Prompt (Miniconda3) using:
conda install theano
conda install pygpu
pip install pymc3
And when I try to import it in Jupyter Notebook:
import pymc3 as pm
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-1f817cf6472a> in <module>
1 # PyMC3 for Bayesian Inference
----> 2 import pymc3 as pm
ModuleNotFoundError: No module named 'pymc3'
Any solutions to this problem guys...
You have installed the pymc3 to other python environment that you are using to import it.
Check your python executable location
Inside your script, use
import sys
print(sys.executable)
To get the path to the python executable you are using. Lets say it is C:\python\python.exe.
Install the package
Then, install the package using
<path_to_python.exe> -m pip install pymc3
This is the bulletproof way installing packages with pip, when you have multiple python installations or virtual environments on your system.

Module h2o not found in anaconda python

I have installed h2o package on anaconda python, however, I get the following error on jupyter notebook:
import h2o
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-accdebc0c7de> in <module>
----> 1 import h2o
ModuleNotFoundError: No module named 'h2o'
From the conda list I can see that the installed h2o version is the following:
conda list h2o
#
# Name Version Build Channel
h2o 3.18.0.2 0 anaconda
(Is it normal that the build version is 0 here?)
The python version is 3.7.4.
I also tried the following
conda install -c h2oai h2o
and I get
# All requested packages already installed.
Any ideas why the h2o package isn't working?
Thanks for your time!
AMC, regarding the anaconda environments, after running:
conda info --envs
I get:
# conda environments:
#
base * C:\Users\ncham***\AppData\Local\Continuum\anaconda3
As far as I can see, there is only one environment...
Here is the official guide for installing H2O on Anaconda.
Jump to the Install on Anaconda Cloud part, make sure your Python's version is compatible with h2o module (2.7,3.5 and 3.6), follow the steps and you will be able to import h2o module through py36 channel.
Hope this answer helps you.

Cannot import category_encoders module

I am not able to import category_encoders module in jupyter notebook in python 3 virtual environment.
Error
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-15-86725efc8d1e> in <module>()
9 from plotly import graph_objs
10 from datetime import datetime
---> 11 import category_encoders as ce
12
13 import sklearn
ModuleNotFoundError: No module named 'category_encoders'
Output of "which pip"
/opt/virtual_env/py3/bin/pip
Output of "pip show category_encoders" is
Name: category-encoders
Version: 1.3.0
Summary: A collection sklearn transformers to encode categorical variables as numeric
Home-page: https://github.com/wdm0006/categorical_encoding
Author: Will McGinnis
Author-email: will#pedalwrencher.com
License: BSD
Location: /opt/virtual_env/py3/lib/python3.6/site-packages
Requires: numpy, pandas, statsmodels, scikit-learn, patsy, scipy
Required-by:
Output of "pip list"
Package Version
------------------- -------
absl-py 0.7.0
astor 0.7.1
backcall 0.1.0
category-encoders 1.3.0
cycler 0.10.0
pip install --upgrade category_encoders
Now,
Restart your kernel
import category_encoders as... so on and so forth
Also,
you can checkout the sk-learn's preprocessing class CategoricalEncoder...
from sklearn.preprocessing import CategoricalEncoder
get sk-learn from here,
pip install git+git://github.com/scikit-learn/scikit-learn.git
or Simply
pip install sklearn
I was using anaconda environment.
Initially, I installed category_encoders using pip (within the conda enviornment) and it failed to resolve. Then I uninstalled ``category_encoders` from pip
pip uninstall category-encoders
and installed it using conda:
conda install -c conda-forge category_encoders
That solved the issue.
If you have given your virtual environment ('py3' for your case) the permission for accessing the system site-packages directory you can try installing the package to your base (root) environment.
Search 'pyvenv.cfg' file in your system and check if it includes:
include-system-site-packages = true
If yes, install the package to your root environment as stated here and try importing it again in your Jupyter Notebook.
You can add a cell above and type ! pip install --upgrade category_encoders
It will install the package without opening a terminal window.

Jupyter gets Import Error when importing matplotlib

I'm just now trying to integrate to Jupyter and I have been using Anaconda for a long while now.
When trying to import the matplotlib in the IPython Notebook,
import matplotlib.pyplot as plt
%matplotlib inline
I get this error:
ImportError Traceback (most recent call last)
<ipython-input-2-385145dcc870> in <module>()
----> 1 import matplotlib.pyplot as plt
2 get_ipython().magic(u'matplotlib inline')
ImportError: No module named matplotlib.pyplot
I faced the same problem. Then I used folllowing command to install matplotlib library to my virtual environment.
pip install matplotlib
Then I could import matplotlib to jupyter notebook.
I think you should install matplotlib library if using conda then in terminal type:
# create a new environment with the required packages
conda create -n "matplotlib_build" python=3.5 numpy python-dateutil pyparsing pytz tornado cycler tk libpng zlib freetype
activate matplotlib_build
# if you want a qt backend, you also have to install pyqt (be aware that pyqt doesn't mix well if
# you have created the environment with conda-forge already activated...)
conda install pyqt
# this package is only available in the conda-forge channel
conda install -c conda-forge msinttypes
# copy the libs which have "wrong" names
set LIBRARY_LIB=%CONDA_PREFIX%\Library\lib
mkdir lib || cmd /c "exit /b 0"
copy %LIBRARY_LIB%\zlibstatic.lib lib\z.lib
copy %LIBRARY_LIB%\libpng_static.lib lib\png.lib
# Make the header files and the rest of the static libs available during the build
# CONDA_DEFAULT_ENV is a env variable which is set to the currently active environment path
set MPLBASEDIRLIST=%CONDA_PREFIX%\Library\;.
# build the wheel
python setup.py bdist_wheel
This code was taken from https://matplotlib.org/users/installing.html#conda-packages. Hope this helps.
Thanks
Michael

Error Importing Python Packages into Jupyter

I've been working in Jupyter IPython notebook (using Python 2.7) and haven't had any issues before this importing and installing packages. Most of my packages were installed via Anaconda. Now I'm randomly having problems importing packages that I've always been able to import. I have an example below. Please help. I'm pretty new to Python so I'm completing stuck on what the problem is and how to fix it.
import pandas as pd
ImportError Traceback (most recent call last)
in ()
----> 1 import pandas as pd
C:\Users\IBM_ADMIN\Anaconda2\lib\site-packages\pandas__init__.py in ()
11 "pandas from the source directory, you may need to run "
12 "'python setup.py build_ext --inplace' to build the C "
---> 13 "extensions first.".format(module))
14
15 from datetime import datetime
ImportError: C extension: No module named numpy not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace' to build the C extensions first.
conda virtual environments will help you a lot. It's good practice to use environments for your projects. And it'll help you avoid causing potential problems with your system's Python.
Try this on the command line:
conda create -n myenv anaconda
source activate myenv
jupyter notebook
That default env will already have pandas; you can install most other things with conda install <package> or, if that doesn't work, pip install <package>.
Running this solved the problem: pip install scipy-0.16.1-cp27-none-win_amd64.whl After doing this, all other packages were able to be re-installed and successfully imported.

Categories