No module named 'mlxtend' - python

I am unable to install the mlextend package in Jupyter Python3 notebook
I have tried pip install mlxtend or pip3 install mlxtend, but either it shows syntax error for some reason on Python2 or it tells to try on the command line in python3. I have tried installing it on command line but it shows "ERROR: Could not find a version that satisfies the requirement mlextend (from versions: none)
ERROR: No matching distribution found for mlextend"
from mlxtend.frequent_patterns import apriori
from mlxtend.frequent_patterns import association_rules
ModuleNotFoundError Traceback (most recent call
last)
<ipython-input-3-73c97be96c5f> in <module>()
----> 1 from mlxtend.frequent_patterns import apriori
2 from mlxtend.frequent_patterns import association_rules
ModuleNotFoundError: No module named 'mlxtend'`enter code here`

You need to use the following command:
pip install mlxtend
You are currently trying to install mlextend (which does not exist) instead of mlxtend.

I had the same issue recently. What worked was importing the module first, and then getting the components:
import mlxtend
from mlxtend.frequent_patterns import apriori
from mlxtend.frequent_patterns import association_rules

To add to the above possible solutions. Under Anaconda/Miniconda environments it is also possible to use conda. Among the various options under https://anaconda.org/conda-forge/mlxtend the following worked for me
conda install -c conda-forge mlxtend

'pip install' works on Python2,if you install for Python3, use
pip3 install mlxtend instead

Use !pip install mlxtend. It will definitely work.

#Import the libraries
#To install mlxtend run : pip install mlxtend
import pandas as pd
from mlxtend.preprocessing import TransactionEncoder
from mlxtend.frequent_patterns import association_rules,apriori

Related

Python Module is already installed but ModuleNotFound

I am still a beginner in Python.
I use Jupyter Notebook and want to import XlsxWriter, but it doesnt seem to work.
This is what I do in the Notebook which i usually open through the pycharm terminal:
import numpy as np
import pandas as pd
import sys
!{sys.executable} -m pip install --user XlsxWriter
import XlsxWriter
However i get the following error message:
Requirement already satisfied: XlsxWriter in c:\users\rober\appdata\local\programs\python\python310\lib\site-packages (3.0.3)
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Input In [8], in <cell line: 6>()
3 import sys
4 get_ipython().system('{sys.executable} -m pip install --user XlsxWriter')
----> 6 import XlsxWriter
ModuleNotFoundError: No module named 'XlsxWriter'
Does anyone have an idea what is the problem here?
A simple Script using XlsxWriter in PyCharm works perfectly fine.
you need to install xlsxwriter first
pip install xlsxwriter
ref : https://bobbyhadz.com/blog/python-no-module-named-xlsxwriter

ModuleNotFoundError: No module named 'mglearn'

This is a commmon question, but nothing worked for me so far.
I have seen this answer too Python 3 on Mac : ModuleNotFoundError: No module named 'mglearn'
!pip install mglearn
!pip install sklearn
!pip install -U scikit-learn
import mglearn
import sklearn
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-fe22f30497b9> in <module>
----> 1 import mglearn
2 import sklearn
ModuleNotFoundError: No module named 'mglearn'
I checked other questions but failed to solve it. I have macOS Catalina 10.15.7
import sys
!{sys.executable} -m pip install mglearn
Try using this. This assures that you are using the pip version associated with the environment.

cannot import sklearn even though it is installed successfully

I have installed sklearn through pip successfully using this command:
$pip install -U scikit-learn
But I cannot import it.
import sklearn
Result:
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-b7c74cbf5af0> in <module>
----> 1 import sklearn
ModuleNotFoundError: No module named 'sklearn'
Please help
You might want to try installing scikit-learn: pip install scikit-learn
Try pip3 install sklearn.
This will install the libraries you need for python 3.

ImportError: cannot import name ExponentialSmoothing

I tried to install statsmodels in python. After installation, I checked with pip freeze. The package can be seen in the list.
When I am trying:
from statsmodels.tsa.api import ExponentialSmoothing, SimpleExpSmoothing, Holt
I am getting error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: cannot import name ExponentialSmoothing
I have tried the following link also :
link
As of today (10 May 2018), the problem is solved by simply installing version 0.9.0 rather than the default 0.8.0:
pip install statsmodels==0.9.0rc1
I met the same situation, and the install process recommended in Nish's url didn't work for me. Here's how did I solve the problem (I'm using Mac OS).
Remove statsmodels library first, if you have installed: pip uninstall statsmodels
In your terminal, type git init, to initiate git
Then type git clone git://github.com/statsmodels/statsmodels.git
Change the directory to statsmodels using “cd statsmodels”
Next type python setup.py install
python setup.py build_ext --inplace
Now type python in your terminal and then type from statsmodels.tsa.api import ExponentialSmoothing, to see whether it can import successfully
If using conda, this will make statsmodel 0.9.0
conda update statsmodels
It is the wrong import,
Try
from statsmodels.tsa.holtwinters import ExponentialSmoothing, SimpleExpSmoothing, Holt
You can follow the steps mentioned below:
Step 1: Remove statsmodel using pip uninstall statsmodel
Step 2: Install git from here: https://git-scm.com/downloads
Step 3: Follow steps mentioned under "Installing library(statsmodels)" from link mentioned below:
https://www.analyticsvidhya.com/blog/2018/02/time-series-forecasting-methods/?utm_source=feedburner&utm_medium=email&utm_campaign=Feed%3A+AnalyticsVidhya+%28Analytics+Vidhya%29

Rodeo: ImportError: No module named 'statsmodels'

I just start to use Rodeo with Python 3.6.2. But there is an error when importing statsmodels under Windows 10. Here is the script:
import pandas as pd
import statsmodels.api as sm
import pylab as pl
import numpy as np
When highlight import statsmodels.api as sm and click Run line, there is an error:
>>> import statsmodels.api as sm
ImportError: No module named 'statsmodels'
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-3-6030a6549dc0> in <module>()
----> 1 import statsmodels.api as sm
ImportError: No module named 'statsmodels'
Then I downloaded the statsmodels from Github and installed it. Here is the output of pip list:
C:\Users\Documents\statsmodels-master\statsmodels-master>pip list
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
Cython (0.26)
numpy (1.13.1)
pandas (0.20.3)
patsy (0.4.1)
pip (9.0.1)
python-dateutil (2.6.1)
pytz (2017.2)
scipy (0.19.1)
setuptools (28.8.0)
six (1.10.0)
statsmodels (0.8.0)
The output shows that statsmodels 0.8.0 is installed. But there is still importing error. It seems that the Rodeo has difficulty to see statsmodels.
UPDATE:
Here is the output of print(sys.pth) in Rodeo. There is a path for the statsmodels.
>>> print(sys.path)
['', 'C:\\Python36\\Scripts', 'c:\\python36\\lib\\site-packages\\statsmodels-0.8.0-py3.6-win-amd64.egg', 'C:\\Python36', 'C:\\Python36\\python36.zip', 'C:\\Python36\\DLLs', 'C:\\Python36\\lib', 'C:\\Python36\\lib\\site-packages', 'C:\\Python36\\lib\\site-packages\\patsy-0.4.1-py3.6.egg', 'C:\\Python36\\lib\\site-packages\\pandas-0.20.3-py3.6-win-amd64.egg', 'C:\\Python36\\lib\\site-packages\\six-1.10.0-py3.6.egg', 'C:\\Python36\\lib\\site-packages\\pytz-2017.2-py3.6.egg', 'C:\\Python36\\lib\\site-packages\\python_dateutil-2.6.1-py3.6.egg', 'C:\\Python36\\lib\\site-packages\\IPython\\extensions', 'C:\\Users\\JunC\\.ipython']
I had the same issue. I solved it by adding the path to statsmodels to rodes>preferences>environment variables. In my case the path was "C:\ProgramData\Miniconda3\pkgs".
You might not have latest version of python2. Either update it, or use python3 instead.
To use python 3, use pip3 instead of pip. So run the following:
pip3 install statsmodels

Categories