10

I'm new to python, so apologies if this is a silly question.

I'm trying to use mlxtend, and have installed it using pip. Pip confirms that it is installed (when I type "pip install mlxtend" it notes that the requirement is already satisfied). However, when I try and import mlxtend in python using "import mlxtend as ml", I get the error: "ModuleNotFoundError: No module named 'mlxtend'". I used the same process for installing and importing pandas and numpy, and they both worked. Any advice?

I should note that I have resorted to dropping in the specific code I need from mlxtend (apriori and association rules), which is working, but hardly a good long term strategy!

I'm using python version 3.6.5.

Thanks!

BK42
  • 101
  • 1
  • 1
  • 4

5 Answers5

7

I was able to install the package by doing below two things:

  1. Run Windows Command as an Administrator (Refer to Import oct2py says access is denied )
  2. Try this command in the Wondows Command:

    conda install mlxtend --channel conda-forge

Nick
  • 138,499
  • 22
  • 57
  • 95
Steve Lee
  • 91
  • 1
  • 5
7

I was faced with the same error when running on Google Colab. here's what fixed for me:

%pip install mlxtend --upgrade
Miguel Tomás
  • 1,714
  • 1
  • 13
  • 23
3

I had the same issue while using Anaconda, I tried to install it with Anaconda, however, Notebook didn't see it installed. You can also try to install it in CMD by just typing

pip install mlxtend --user or pip3 install mlxtend --user

After installing it with CMD, Notebook didn't give error for my case. Just reply if this helps. Good luck all.

Nijat Mursali
  • 930
  • 1
  • 8
  • 20
2

I have the same issue when I use this library with python 3.7 but it is working for python 2.7 and I don't know why!.

My workaround is to download the source code and import each file you need that way.

Habib Karbasian
  • 556
  • 8
  • 18
1

Try this:

conda install -c conda-forge mlxtend

Don't mix pip and Conda environments. Last time I did this I broke my Python and needed to reinstall everything again.

If you must deal with different environments using pip and conda because of many projects, use pyenv.