umap icon indicating copy to clipboard operation
umap copied to clipboard

No module named 'umap'

Open AlejandroTL opened this issue 4 years ago • 10 comments

Hi!

I have installed the package umap-learn in my conda environment with conda install -c conda-forge umap-learn, and I see it installated in my conda list:

...
umap-learn                0.4.6            py37hc8dfbb8_0    conda-forge
...

But when importing it to my jupyter notebook or python script, always the same error:

import umap

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-3-93137e0fcb10> in <module>
----> 1 import umap

ModuleNotFoundError: No module named 'umap'

Have tried too with import umap.umap_ but keeps not working... This thing is driving my crazy. I already uninstalled and installed umap-learn three times.

Thanks! :)

-- UPDATE --

The problem is solved. I started a new environment with Python 3.7 and it works perfectly. I suspect that maybe the Python version or another package was creating a problem because the version of some background package, I don't know.

To everyone with this problem I recommend you to create a new environment, install umap-learn at the beginning and it should work.

Thanks :)

AlejandroTL avatar Dec 14 '20 14:12 AlejandroTL

Are you sure that your using the right environment in your jupiter notebook? I've been caught out in the past by my jupiter not seeing the python kernel that I installed packages into. An easy test is to install some other package from conda-forge and see if you can import it.

On Mon, Dec 14, 2020, 9:10 AM AleTL [email protected] wrote:

Hi!

I have installed the package umap-learn in my conda environment with conda install -c conda-forge umap-learn, and I see it installated in my conda list:

... umap-learn 0.4.6 py37hc8dfbb8_0 conda-forge ...

But when importing it to my jupyter notebook or python script, always the same error:

import umap


ModuleNotFoundError Traceback (most recent call last) in ----> 1 import umap

ModuleNotFoundError: No module named 'umap'

Have tried too with import umap.umap_ but keeps not working... This thing is driving my crazy. I already uninstalled and installed umap-learn three times.

Thanks! :)

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lmcinnes/umap/issues/534, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC3IUWUXT2SCD7UYX6MMBM3SUYMFTANCNFSM4U2ZR74A .

jc-healy avatar Dec 14 '20 18:12 jc-healy

Hey!

I'm super sure, I checked it more than hundred times. Besides, I have just installed Tkinter from conda-forge just to see if for some reason conda-forge packages give me problems and it works. I don't know what's happening... If I run a python script, it works. The problem is with the Jupyter Notebook...

Are you sure that your using the right environment in your jupiter notebook? I've been caught out in the past by my jupiter not seeing the python kernel that I installed packages into. An easy test is to install some other package from conda-forge and see if you can import it. On Mon, Dec 14, 2020, 9:10 AM AleTL @.***> wrote: Hi! I have installed the package umap-learn in my conda environment with conda install -c conda-forge umap-learn, and I see it installated in my conda list: ... umap-learn 0.4.6 py37hc8dfbb8_0 conda-forge ... But when importing it to my jupyter notebook or python script, always the same error: import umap --------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) in ----> 1 import umap ModuleNotFoundError: No module named 'umap' Have tried too with import umap.umap_ but keeps not working... This thing is driving my crazy. I already uninstalled and installed umap-learn three times. Thanks! :) — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#534>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC3IUWUXT2SCD7UYX6MMBM3SUYMFTANCNFSM4U2ZR74A .

AlejandroTL avatar Dec 14 '20 20:12 AlejandroTL

I've got an update.

Don't know why, but I restart my computer and it suddenly start working. The point now is that I do reducer = umap.UMAP() and appears this error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-3-c70b1b7366b8> in <module>
      3 
      4 sns.set(style='white', context='notebook', rc={'figure.figsize':(14,10)})
----> 5 reducer = umap.UMAP()
      6 embedding = reducer.fit_transform(data_pca)
      7 embedding.shape

AttributeError: module 'umap' has no attribute 'UMAP'

Does anyone know why?

AlejandroTL avatar Dec 14 '20 21:12 AlejandroTL

I also had an import error after pip installing, but conda installing worked.

fritzo avatar Dec 30 '20 03:12 fritzo

@AlejandroTL the only time I've seen that error is when someone has accidentally installed the wrong UMAP: https://pypi.org/project/umap/ is not the same as https://pypi.org/project/umap-learn/

you can also check via help(umap) because it should look like this:

Help on package umap:

NAME
    umap

PACKAGE CONTENTS
    aligned_umap
    distances
    layouts
    parametric_umap
    plot
    sparse
    spectral
    umap_
    utils
    validation

FUNCTIONS
    warn(message, category=None, stacklevel=1, source=None)
        Issue a warning, or maybe ignore it or raise an exception.

VERSION
    0.5.0

FILE
    /home/dking/anaconda3/envs/umap/lib/python3.8/site-packages/umap/__init__.py

if it looks like anything else that may be the issue. My best advice is just full reinstall using the patterns from the README.md

dylanking42 avatar Jan 13 '21 16:01 dylanking42

@AlejandroTL the only time I've seen that error is when someone has accidentally installed the wrong UMAP: https://pypi.org/project/umap/ is not the same as https://pypi.org/project/umap-learn/

you can also check via help(umap) because it should look like this:

Help on package umap:

NAME
    umap

PACKAGE CONTENTS
    aligned_umap
    distances
    layouts
    parametric_umap
    plot
    sparse
    spectral
    umap_
    utils
    validation

FUNCTIONS
    warn(message, category=None, stacklevel=1, source=None)
        Issue a warning, or maybe ignore it or raise an exception.

VERSION
    0.5.0

FILE
    /home/dking/anaconda3/envs/umap/lib/python3.8/site-packages/umap/__init__.py

if it looks like anything else that may be the issue. My best advice is just full reinstall using the patterns from the README.md

I'm super sure that I installed 'umap-learn'. Recently I faced the same problem with a new environment I created, but I realize that this problem only appears on VSCode, I don't know why. If I tried to run the code in Jupyter Lab it works, but in VSCode it fails. Maybe it's just coincidence, but it was done with a raw environment, just being installed 'umap-learn'. Anyway, VSCode caused some problems running Jupyter Notebooks with other packages and functionalities.

AlejandroTL avatar Jan 24 '21 21:01 AlejandroTL

I'm having a similar issue. You said it was solved with a new environment? How exactly did you do that?

himaniyadav avatar Feb 10 '21 03:02 himaniyadav

I'm having a similar issue. You said it was solved with a new environment? How exactly did you do that?

Hey!

I think that the problem was in the Visual Studio Code, do you use it? I use now Jupyter Lab and it's working. Anyway, what I did was create a new environment with Python and then install umap, before installing anything else.

AlejandroTL avatar Feb 10 '21 14:02 AlejandroTL

I was facing the same issue. After different cheks, I arrived at thee foolowing:

>>> import umap
ImportError: Numba needs NumPy 1.20 or less
>>> import numpy as np; np.__version__
'1.21.2'

so I did

pip install numpy==1.20

and it now works fine

import umap

numpy is a requirement for a few different libraries that I use in my venv, and the versions were clashing.

louisguitton avatar Aug 30 '21 22:08 louisguitton

I was facing the same issue. After different cheks, I arrived at thee foolowing:

>>> import umap
ImportError: Numba needs NumPy 1.20 or less
>>> import numpy as np; np.__version__
'1.21.2'

so I did

pip install numpy==1.20

and it now works fine

import umap

numpy is a requirement for a few different libraries that I use in my venv, and the versions were clashing.

This worked for me as well.

sm185597 avatar Sep 26 '22 16:09 sm185597