umap: Attribute Error

Hi there, these are my system specs: macOS Sierra 10.12.3 (16D32)

I have installed umap through pip. When I try to run it this the error message that comes up. I’m unsure what the problem is, any ideas?

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-10-68ef34dfa695> in <module>()
     16         umap_mfccs = get_scaled_umap_embeddings(mfcc_features,
     17                                                 neighbours,
---> 18                                                 distances)
     19         umap_embeddings_mfccs.append(umap_mfccs)
     20 

<ipython-input-10-68ef34dfa695> in get_scaled_umap_embeddings(features, neighbour, distance)
      1 def get_scaled_umap_embeddings(features, neighbour, distance):
      2 
----> 3     embedding = umap.UMAP(n_neighbors=neighbour,
      4                           min_dist = distance,
      5                           metric = 'correlation').fit_transform(features)

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

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 3
  • Comments: 23 (4 by maintainers)

Commits related to this issue

Most upvoted comments

I also had the same issue (import umap; umap.UMAP returns AttributeError: module 'umap' has no attribute 'UMAP') (MacOS, High Sierra, installed via pip).

As a workaround import umap.umap_ as umap seems to work instead of import umap

Hi, I can’t say for sure but potentially it may be that you actually have the wrong umap. Due to name collisions the UMAP algorithm code is under the name umap-learn on PyPI so if you did

pip install umap

you will get a different package that does not to what you want.

If that is the case then you’ll want

pip uninstall umap
pip install umap-learn

If that is not the problem then there is something else wrong that is going to be harder to diagnose. Either way, please let me know, and sorry about the naming confusion on pip.

I encountered this error due to having named my python-file umap.py. Felt quite silly and changed filename, which solved the problem.

Actually, I have used the following: pip uninstall umap

pip install umap-learn

Now on the notebook: import umap.umap_ as umap reducer=umap.UMAP()

It works well.

I was facing the same problem too, I’m suing windows, conda versions, and what i did is that pip uninstall umap-learn pip install umap-learn and then follow it pip install umap

it just worked !

The best I can offer is that you need to make sure that the mapping based umap package has been completely purged from your python install before trying to install umap-learn. I would suggest finding the relevant site-packages directory and removing any and all files and directories there that start with umap and then trying to re-install umap-learn.

I just encountered this common problem today. Working from within a Jupyter Notebook I performed:

!pip install umap

Then

import umap
reducer = umap.UMAP()

caused the common error here. I installed ‘umap-learn’ but to no avail.

I corrected the issue by uninstalling ‘umap’, then also uninstalling ‘umap-learn’, then reinstalling ‘umap-learn’ and restarting my kernel:

!pip uninstall umap
!pip uninstall umap-learn
!pip install umap-learn

With this solution, I was then successful with:

import umap
reducer = umap.UMAP()

Thanks for your excellent work on this package @lmcinnes . I know the problem is not related to the package itself, but just wanted to document it for tracking purposes. FYI I also ran into the same issue yesterday. I think I installed the other umap first then figured out that umap-learn was the right choice. After uninstalling the incorrect umap I had to still do a bunch of installs and uninstalls of umap-learn using conda and pip. Finally I made sure that site-packages was clean and did a few more installs. Finally got it to work. So there was lots of frustration, but eventually got it to work.

I am getting this problem too now upon my very first attempt to use UMAP. 😦 I have taken care to only install umap-learn and not umap to begin with. The import umap.umap_ as umap workaround fails too.

Running from a Jupyter notebook with python 3.6 on an Ubuntu machine.

I also had the same issue (import umap; umap.UMAP returns AttributeError: module 'umap' has no attribute 'UMAP') (MacOS, High Sierra, installed via pip).

As a workaround import umap.umap_ as umap seems to work instead of import umap

This seemed to get me around the original error (after also switching to installing umap-learn instead), but then my kernel died on attempting umap.UMAP().fit_transform().

(Datalab running on a Google Cloud Dataproc cluster)