pythonsetuptoolsattributeerrorhmmlearn

Error when importing HMM package (hmmlearn)


When I try to import the hmmlearn package with import hmmlearn, I get this error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-9-036832e0c673> in <module>
----> 1 import hmmlearn

~\Anaconda3\envs\py385\lib\site-packages\hmmlearn\__init__.py in <module>
      9 try:
     10     import setuptools_scm
---> 11     __version__ = setuptools_scm.get_version(  # xref setup.py
     12         root="../..", relative_to=__file__,
     13         version_scheme="post-release", local_scheme="node-and-date")

AttributeError: module 'setuptools_scm' has no attribute 'get_version'

I'm in a python 3.8.5 env on a windows machine. In other environments on this machine (e.g. py 3.7) I don't get the error. Also on my MacOs machine in an 3.8.5 env I can import the package without any problems. In all cases I used pip install hmmlearn to get the package.

I uninstalled and re-installed the hmmlearn and the setuptools_scm package, but that didn't fix it.

It seems like the is a problem with my setuptools_scm package. How can this be fixed? Is there a way to completely remove the hmm package and all its dependencies and do a "clean" re-install?


Solution

  • I had the same problem on Windows and python 3.8.5. For me, uninstalling the hmmlearn and setuptools_scm and then reinstalling it with conda (I'm in a conda environment) fixed it.

    So I did:

    pip uninstall hmmlearn
    pip uninstall setuptools_scm
    

    and then

    conda install -c conda-forge setuptools_scm
    conda install -c conda-forge hmmlearn
    

    Also, I restarted the kernel in jupyter notebook.

    But I'm not sure if that was really the problem, since I can't recreate the problem by uninstalling it over conda and reinstalling the packages over pip.