import error in python hmmlearn - python

I am trying to install python hmmlearn library to build continuous HMM. I have installed all the dependencies and the hmmlearn library from GitHub. The installation completes successfully.
...
Processing dependencies for hmmlearn==0.2.1
Searching for scikit-learn==0.18.1
Best match: scikit-learn 0.18.1
Adding scikit-learn 0.18.1 to easy-install.pth file
Using /usr/local/lib/python2.7/dist-packages
Finished processing dependencies for hmmlearn==0.2.1
But in python, when I try to import GaussianHMM using
from hmmlearn.hmm import GaussianHMM
it gives some import error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "hmmlearn/hmm.py", line 22, in <module>
from .base import _BaseHMM
File "hmmlearn/base.py", line 13, in <module>
from . import _hmmc
ImportError: cannot import name _hmmc

The problem is in hmmlearn/setup.py which doesn't list utils as a submodule.
Add this line to setup.py config.add_subpackage("utils")
## -18,7 +18,7 ## def configuration(parent_package='', top_path=None):
include_dirs=[numpy.get_include()],
libraries=libraries,
)
-
+ config.add_subpackage("utils")
return config
if __name__ == '__main__':

Related

Import librosa gives "no module named numba.decorators", how to solve?

I installed librosa, and now im trying to import it
import librosa
This throws me this error for some reason
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\Asish nayak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\librosa\__init__.py", line 12, in <module>
from . import core
File "C:\Users\Asish nayak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\librosa\core\__init__.py", line 125, in <module>
from .time_frequency import * # pylint: disable=wildcard-import
File "C:\Users\Asish nayak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\librosa\core\time_frequency.py", line 11, in <module>
from ..util.exceptions import ParameterError
File "C:\Users\Asish nayak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\librosa\util\__init__.py", line 77, in <module>
from .utils import * # pylint: disable=wildcard-import
File "C:\Users\Asish nayak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\librosa\util\utils.py", line 15, in <module>
from .decorators import deprecated
File "C:\Users\Asish nayak\AppData\Local\Programs\Python\Python38-32\lib\site-packages\librosa\util\decorators.py", line 9, in <module>
from numba.decorators import jit as optional_jit
ModuleNotFoundError: No module named 'numba.decorators'
Why am i getting this error even after installing the library?
You have to install numbra version 0.48 because of a bug, run
pip install numba==0.48
Librosa Issue on Github
You need to use any numba version before 0.8.0
However, the most recent librosa is not compatible with any numba below 0.48.
At least, that's what I've found from using it on Windows. My solution was to use google colaboratory as it didn't give me any error when importing librosa.
I've got the exact error. Solved it with
pip uninstall --yes librosa
pip install librosa --force-reinstall
Your python version should be 3.8.

Error when importing sklearn in python - ImportError

I get an error when importing sklearn in python.
I am using MacBook.
>>> import sklearn
Error:
> Traceback (most recent call last): File
> "<pyshell#1>", line 1, in <module>
> import sklearn File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sklearn/__init__.py",
> line 81, in <module>
> from . import __check_build # noqa: F401 ImportError: cannot import name '__check_build' from 'sklearn'
> (/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sklearn/__init__.py)
According to the pypi page for sklearn, you should be using pip install scikit-learn instead of pip install sklearn
Your requirements.txt file needs the line
scikit-learn==0.22.1
or, if you're not storing requirements for the project, then
pip install scikit-learn
on the command line.

I can`t import scikit -learn on python3. how can i import it?

I installed numpy-1.13.1+mkl-cp36-cp36m-win32 .whl and scipy-0.19.1-cp36-cp36m-win32.whl successfully, then I installed scikit-learn successfully, but when I ran import sklearn,
pycharm gave me errors. How can I remove this problem?
I installed python3.6 (32bit) on windows 10 (64bit).
import sklearn
result of run:
C:\Users\Emertat\AppData\Local\Programs\Python\Python36-32\python.exe "F:/Python/NS videos/cedes/Exercise 07 test.py"
Traceback (most recent call last):
File "F:/Python/NS videos/cedes/Exercise 07 test.py", line 21, in <module>
import sklearn
File "C:\Users\Emertat\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sklearn\__init__.py", line 134, in <module>
from .base import clone
File "C:\Users\Emertat\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sklearn\base.py", line 12, in <module>
from .utils.fixes import signature
File "C:\Users\Emertat\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sklearn\utils\__init__.py", line 11, in <module>
from .validation import (as_float_array,
File "C:\Users\Emertat\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sklearn\utils\validation.py", line 18, in <module>
from ..utils.fixes import signature
File "C:\Users\Emertat\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sklearn\utils\fixes.py", line 144, in <module>
from scipy.sparse.linalg import lsqr as sparse_lsqr # noqa
File "C:\Users\Emertat\AppData\Local\Programs\Python\Python36-32\lib\site-packages\scipy\sparse\linalg\__init__.py", line 117, in <module>
from .matfuncs import *
File "C:\Users\Emertat\AppData\Local\Programs\Python\Python36-32\lib\site-packages\scipy\sparse\linalg\matfuncs.py", line 19, in <module>
import scipy.special
File "C:\Users\Emertat\AppData\Local\Programs\Python\Python36-32\lib\site-packages\scipy\special\__init__.py", line 640, in <module>
from ._ufuncs import *
ImportError: DLL load failed: The specified procedure could not be found.
Process finished with exit code 1
First, Remove the sklearn form your Windows OS by using the following command-
pip uninstall scikit-learn
Then, you need to install numpy and scipy from their own official installers.
Wheel packages (.whl files) for scikit-learn from pypi can be installed with the pip utility. Open a console and type the following to install or upgrade scikit-learn to the latest stable release:
pip install -U scikit-learn
If there are no binary packages matching your python, version you might to try to install scikit-learn and its dependencies from christoph gohlke unofficial windows installers or from a python distribution instead.

Python import error no module named bz2

I have libbz2-dev installed however I am still getting the following import error while importing gensim :
>>> import gensim
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/krishna/gensimenv/lib/python2.7/site-packages/gensim/__init__.py", line 6, in <module>
from gensim import parsing, matutils, interfaces, corpora, models, similarities, summarization
File "/home/krishna/gensimenv/lib/python2.7/site-packages/gensim/corpora/__init__.py", line 14, in <module>
from .wikicorpus import WikiCorpus
File "/home/krishna/gensimenv/lib/python2.7/site-packages/gensim/corpora/wikicorpus.py", line 21, in <module>
import bz2
ImportError: No module named bz2
you can try to do
pip install bz2file
I'm having the same issue and the tip above didn't resolve it.
Perhaps before creating the virtual env you need to:
sudo apt-get install libbz2-dev
related:
missing python bz2 module

ImportError: cannot import name chardet

Hi i have written a python scraper in which i am importing requests and Beautiful soup module . I am using python2.7 .
I am crating Windows executable (.exe) from my Python script using py2exe module.
For that i have created setup.py as following :
from distutils.core import setup
import py2exe
import requests
packages = [
'requests',
'requests.packages',
'requests.packages.chardet',
'requests.packages.urllib3',
'requests.packages.urllib3.packages',
'requests.packages.urllib3.contrib',
'requests.packages.urllib3.util',
'requests.packages.urllib3.packages.ssl_match_hostname',
]
setup(
console=['CompanyScraper-1.6.py']
)
I have created .exe file by running command "python setup.py py2exe".
But while running the .exe file on window it throwing following error:
Traceback (most recent call last):
File "CompanyScraper-1.6.py", line 13, in <module>
File "requests\__init__.pyc", line 58, in <module>
File "requests\utils.pyc", line 26, in <module>
File "requests\compat.pyc", line 7, in <module>
ImportError: cannot import name chardet
i could not undaerstand why this chardet import error though i have included package into setup.py
Thanks you for looking into my issue.
As you can see from the traceback -
Traceback (most recent call last):
File "CompanyScraper-1.6.py", line 13, in <module>
File "requests\__init__.pyc", line 58, in <module>
File "requests\utils.pyc", line 26, in <module>
File "requests\compat.pyc", line 7, in <module>
ImportError: cannot import name chardet
You have a requests directory with a __init__.py . This is masking the requests package from the library , so when you try to import chardet or any such thing from requests library , it tries to search for it in this local package, and not the library one.
The best solution for this would be to rename the directory and your local package from requests to something else, so that the name does not conflict with any library packages.

Categories