Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

from sklearn.base import BaseEstimator, TransformerMixin ImportError: No module named base #25

Open
josephernest opened this issue Sep 26, 2018 · 8 comments

Comments

@josephernest
Copy link

When doing:

import tfr

I get this error:

    from sklearn.base import BaseEstimator, TransformerMixin
ImportError: No module named base

It's true that no base.py exists in this directory: https://github.com/bzamecnik/tfr/tree/master/tfr

I am on Windows 7, Python 2.7 64 bit, I already have scikit-learn, numpy, scipy, installed, etc.

@bzamecnik
Copy link
Owner

That's strange, since these classes seems to be still that sklearn package. Note that the base module is from sklearn, not tfr.

On fresh install at OSX/Python 3.7 it works for me. Make sure sklearn is properly installed.

@bzamecnik
Copy link
Owner

Aah, on Python 2.7 I got the same error!

>>> import tfr
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/bzamecnik/.virtualenvs/tfr-test/lib/python2.7/site-packages/tfr/__init__.py", line 4, in <module>
    from .sklearn import PitchgramTransformer
  File "/Users/bzamecnik/.virtualenvs/tfr-test/lib/python2.7/site-packages/tfr/sklearn.py", line 1, in <module>
    from sklearn.base import BaseEstimator, TransformerMixin
ImportError: No module named base

Aha, the problem is in the line from sklearn.base import BaseEstimator, TransformerMixin and the module tfr.sklearn. In python 2 it performs a relative import!

What's missing is:

from __future__ import absolute_import

I'll fix it. Thanks for a bug report!

@josephernest
Copy link
Author

Isn't it because your file is called sklearn.py too (https://github.com/bzamecnik/tfr/blob/master/tfr/sklearn.py), so there's maybe a conflict between your sklearn.py and the sklearn module ;)

@josephernest
Copy link
Author

Thanks! it works with from __future__...

Another little bug when doing this with Py 2.7 for win, on a 96khz stereo 16 bit wav file:

import tfr
signal_frames = tfr.SignalFrames('test.wav')

here it is:

  File "C:\Python27\lib\site-packages\tfr\signal.py", line 56, in __init__
    self.frames = self._split_to_frames(signal, frame_size, hop_size)
  File "C:\Python27\lib\site-packages\tfr\signal.py", line 81, in _split_to_frames
    for start in range(0, hop_size * frame_count, hop_size))
TypeError: range() integer end argument expected, got float.

@bzamecnik
Copy link
Owner

Actually the package was never tested for Python 2 :)

I've done a few fixes (from future import ...) to make it pass tests in Python 2. It will be released in a moment.

@bzamecnik
Copy link
Owner

Please check tfr-0.2.4 if it works well in Python 2.

@josephernest
Copy link
Author

Thanks @bzamecnik. Can I install it with pip install tfr-0.2.4? Or pip install tfr==... ? What's the command again?

@bzamecnik
Copy link
Owner

Just pip install -U tfr to upgrade.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants