question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unable to import FeatureHasher with scikit-learn 0.22

See original GitHub issue

Description

Importing FeatureHasher results in an ImportError

Steps/Code to Reproduce

from sklearn.feature_extraction import FeatureHasher

Expected Results

Example: No error is thrown.

Actual Results

Traceback (most recent call last): File “<stdin>”, line 1, in <module> File “/home/franz/.local/lib/python3.6/site-packages/sklearn/feature_extraction/init.py”, line 8, in <module> from ._hashing import FeatureHasher ImportError: cannot import name ‘FeatureHasher’

However, it’s working with 0.21

Versions

System: python: 3.6.9 (default, Nov 7 2019, 10:44:02) [GCC 8.3.0] executable: /usr/bin/python3 machine: Linux-4.15.0-72-generic-x86_64-with-Ubuntu-18.04-bionic

Python dependencies: pip: 9.0.1 setuptools: 41.6.0 sklearn: 0.22 numpy: 1.17.4 scipy: 1.3.3 Cython: 0.29.13 pandas: 0.25.3 matplotlib: 3.1.1 joblib: 0.14.1

Built with OpenMP: True

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
FranzForstmayrcommented, Dec 13, 2019

Hi,

thanks a lot, you were right. When executing the following:

----@----:~$ pip3 uninstall scikit-learn
...
  /home/ecs/.local/lib/python3.6/site-packages/sklearn/utils/tests/test_utils.py
  /home/ecs/.local/lib/python3.6/site-packages/sklearn/utils/tests/test_validation.py
  /home/ecs/.local/lib/python3.6/site-packages/sklearn/utils/validation.py
  /home/ecs/.local/lib/python3.6/site-packages/sklearn/utils/weight_vector.cpython-36m-x86_64-linux-gnu.so
Proceed (y/n)? y
  Successfully uninstalled scikit-learn-0.21.3
----@----:~$ pip3 uninstall scikit-learn
Uninstalling scikit-learn-0.21.0:
  /home/ecs/.local/lib/python3.6/site-packages/scikit_learn-0.21.0.dist-info/INSTALLER
  /home/ecs/.local/lib/python3.6/site-packages/scikit_learn-0.21.0.dist-info/METADATA
  /home/ecs/.local/lib/python3.6/site-packages/scikit_learn-0.21.0.dist-info/RECORD
  /home/ecs/.local/lib/python3.6/site-packages/scikit_learn-0.21.0.dist-info/WHEEL
  /home/ecs/.local/lib/python3.6/site-packages/scikit_learn-0.21.0.dist-info/top_level.txt
Proceed (y/n)? y
  Successfully uninstalled scikit-learn-0.21.0
----@----:~$ pip3 uninstall scikit-learn

You can see there were actually two scikit-learn versions (0.21.0 and 0.21.3) installed. Solved for me!

0reactions
glemaitrecommented, Dec 13, 2019

Be aware of https://github.com/scikit-learn/scikit-learn/issues/15884. On some Ubuntu distribution pip3 let some *.so file during updating. Then, there a name conflict and we need to remove manually some the *.so files (_online_lda.cython***.so and _hashing.cython***).

Read more comments on GitHub >

github_iconTop Results From Across the Web

sklearn.feature_extraction.FeatureHasher in sklearn 0.22
The package that you are using is not scikit-learn 0.22. In the traceback, the module imported is hashing.py and has been renamed ...
Read more >
Release Highlights for scikit-learn 0.22
We are pleased to announce the release of scikit-learn 0.22, which comes with many bug fixes and new features! We detail below a...
Read more >
8. Computing with scikit-learn - 书栈网 · BookStack - 书栈网
Currently the preferred way to do this is touse the so-called hashing trick as implemented by sklearn.feature_extraction.FeatureHasher for ...
Read more >
Sklearn.Multioutput · sklearn 0.22-0.2.0 · OCaml Packages
If the dtype of X is object, attempt converting to float, raising on failure. Parameters ---------- X : nd-array, list or sparse matrix...
Read more >
digitrecog | Kaggle
tpot 0.11.5 requires scikit-learn>=0.22.0, but you'll have scikit-learn 0.21.3 which is incompatible. sklearn-pandas 2.0 ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found