I am new to python, and trying to run this example in Jupyter notebook. Whenever I run following
import os
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from statsmodels.tsa.api import SimpleExpSmoothing
It gives me following error
ImportError Traceback (most recent call last)
<ipython-input-5-a15788c08ca7> in <module>()
3 import pandas as pd
4 import matplotlib.pyplot as plt
----> 5 from statsmodels.tsa.api import SimpleExpSmoothing
ImportError: cannot import name 'SimpleExpSmoothing'
Although, I have installed statsmodels (0.8.0) by
pip install statsmodels
like other packages (numpy, pandas etc.). I checked on git, api file contains this method but my api file (obtained through pip) doesn't have this method. Maybe I am not getting the git version (seems latest one) through pip? I am working in windows and I also tried on mac OSX, and result is same. I tried to do a copy/paste attempt for missing files/code in files from git (not a good way) but it doesn't help. I would appreciate your suggestions here.
EDIT
So the solution for Jupyter (thanks to #user333700) is to install master branch directly from git by
pip install git+https://github.com/statsmodels/statsmodels.git
I am extending my question for PyCharm, how can I add a git package within PyCharm? This link does not help.
For future reference another solution which worked for me is to pip install the latest version directly:
pip install statsmodels==0.9.0rc1
Related
I'm having trouble importing a python package called "scanpy" into a Jupyter Notebook. Following #ecjb's advice here (Python - package not found although it is installed), which was basically to specify the python/pip installation I wanted to use when installing "joblib," I've tried to specify the pip and python and install joblib but I can't seem to get it working.
import numpy as np
import pandas as pd
!/software/miniconda3/4.10.3/bin/pip install joblib
import joblib
import scanpy as sc
Defaulting to user installation because normal site-packages is not writeable
Looking in indexes: https://pypi.org/simple, https://pypi.ngc.nvidia.com
Requirement already satisfied: joblib in /home/atp9753/.local/lib/python3.9/site-packages (1.1.0)
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-19-9bd6abfc0151> in <module>
2 import pandas as pd
3 get_ipython().system('/software/miniconda3/4.10.3/bin/pip install joblib')
----> 4 import joblib
5 import scanpy as sc
ModuleNotFoundError: No module named 'joblib'
I've also tried deleting my virtual environment and recreating it, and several other things. If someone could offer some help, I would be really grateful.
EDIT:
This seems to me to be the oddest error:
~/.local/lib/python3.6/site-packages/sklearn/utils/_joblib.py in <module>
6 # versions
7 import joblib
----> 8 from joblib import logger
9 from joblib import dump, load
10 from joblib import __version__
By installing it from the source, I've got it to import "joblib" but now it won't install joblib's modules. Does anyone happen to know a reason for this?
To get the latest code using git, just type:
git clone git: //github.com/joblib/joblib.git
If you don't have git installed, you can download a zip or tarball of the latest code:
http://github.com/joblib/joblib/archives/master
After installing git, proceed to install joblib from the directory
example:
python setup.py installation
try this way to see
I'm trying to learn PyCaret but having a problem when trying to import it in Jupyter Lab.
I'm working in a virtualenv and installed pycaret via pip:
pip install pycaret
I can confirm its installed via pip list:
prompt-toolkit 3.0.7
protobuf 3.13.0
py 1.9.0
pycaret 2.1.2
pycparser 2.20
The very first line in the notebook is:
from pycaret.nlp import *
however this results in:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-3-7c206b4a9ead> in <module>
----> 1 from pycaret.nlp import *
2 import psycopg2
3 import sys, os
4 import numpy as np
5 import pandas as pd
ModuleNotFoundError: No module named 'pycaret'
I'm pulling my hair out trying to figure this out and can't find anyone else with something similar.
I've tried to import via the python shell as well and that works perfectly.
You should create a seperate environment for installing time series alpha module
after creating a new environment and switching into
pip install pycaret-ts-alpha
and then you will be able to access
https://towardsdatascience.com/announcing-pycarets-new-time-series-module-b6e724d4636c
I forgot that you had to install modules via Jupyter.
Following this guide: http://jakevdp.github.io/blog/2017/12/05/installing-python-packages-from-jupyter/index.html
Installing like so:
# Install a pip package in the current Jupyter kernel
import sys
!{sys.executable} -m pip install numpy
Got it working
First Create a new environment conda documentation
Second Download the Pycaret with this instruction
Third check your sklearn version is greater thansklearn>=0.23.2.
Because if it's greater PyCaret is not compatible with that.
Nothing works for you? Download directly from github with this command
pip install git+https://github.com/pycaret/pycaret.git#egg=pycaret
I read on the tutorial page of pycaret that to install it through a Jupyter-notebook you should add an exclamation mark in front of the python command in the Jupyter-cell:
!pip install pycaret
I'm new to python and Anaconda and I tried to run my code which contains Levenshtein import, however, it shows me this error:
ImportError Traceback (most recent call last)
<ipython-input-1-896847aaaa86> in <module>()
1 import pandas as pd
2 import numpy as np
----> 3 import Levenshtein as lv
4 import math
5 import re
ImportError: No module named 'Levenshtein'
Any recommendations regarding this, I owe you tons of thanks
The error happens because Anaconda does not ship with the Levenshtein package. You'll have to install it.
Usually, you want to install python packages on Jupyter Notebook by using the conda command. I was having trouble installing this package in particular on a Windows, however, simply because Windows Defender held out the process indefinitely.
The way I managed to install it as by using pip in Windows's cmd. First you have to figure out were the python executable from your Notebook is running.
In your notebook:
import sys
{sys.executable}
Copy the path the cell outputs, open the cmd. There, use the following command:
[PASTE THE PATH HERE] -m pip install python-levenshtein
After that you should be able to import Levenshtein.
First bear with me as I am relatively new to coding. I am trying to import numpy to Jupyter (localhost, webbased) using Python 3 and getting an error.
import numpy as np
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-7-0aa0b027fcb6> in <module>()
----> 1 import numpy as np
ModuleNotFoundError: No module named 'numpy'
What should I do? Many thanks.
Maybe try download Anaconda and using that as your interpreter. Pretty sure that comes preinstalled with Numpy.
Or check that you are following the correct way for installing the python 3 version: think this might help: Install numpy on python3.3 - Install pip for python3
have you tried !pip install numpy in hte python Notebook cell?
I had the same problem despite correct version of Python and numpy on my Ubuntu. Then I tried something that worked in Google Colab:
!pip install numpy
After that I was able to import numpy without further complications.
Importing scipy in iPython gave me:
In [1]: import scipy
-----------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-4dc45f4c0083> in <module>()
----> 1 import scipy
/usr/local/lib/python2.7/site-packages/scipy/__init__.py in <module>()
/usr/local/lib/python2.7/site-packages/scipy/_lib/_ccallback.py in <module>()
ImportError: cannot import name _ccallback_c
In [2]:
Did a complete update of all the files of Anaconda
> conda update --all
and the error remains. Did a complete search on the web and there are similar problems but without solutions. Can you help me?
i am giving you two solutions which might work by my expereince
1. create a virtualenv and install the scipy package in that virtualenv and give path like this
import sys
sys.path.append('/home/shashi/.virtualenvs/venv/lib/python2.7/site-packages/')
import scipy
2.
Download the source code https://github.com/scipy/scipy/archive/v0.18.0-1.zipand unpack it. Open a command window in the folder where the setup.py of the module is located and type
scipy python setup.py install
It looks like scipy is not installed
conda install -c anaconda scipy
Try this and let us know if you receive the error again
Cheers!