SciPy compatibility issue with MKL libraries - python

I recently installed SciPy for Python3.4 on Ubuntu 12.04 with
pip3 install scipy
When I import scipy in Python3.4 as:
import scipy
it imports, but when I import the function interpolate as
import scipy.interpolate
I get the following error:
File "test.py", line 55, in <module>
import scipy.interpolate
File "/home//.pyenv/versions/3.4.1/lib/python3.4/site-packages/scipy/interpolate/__init__.py", line 158, in <module>
from .interpolate import *
File "/home/nxkr/.pyenv/versions/3.4.1/lib/python3.4/site-packages/scipy/interpolate/interpolate.py", line 11, in <module>
import scipy.linalg
File "/home/nxkr/.pyenv/versions/3.4.1/lib/python3.4/site-packages/scipy/linalg/__init__.py", line 175, in <module>
from .basic import *
File "/home/nxkr/.pyenv/versions/3.4.1/lib/python3.4/site-packages/scipy/linalg/basic.py", line 21, in <module>
from ._solve_toeplitz import levinson
ImportError: /home/nxkr/.pyenv/versions/3.4.1/lib/python3.4/site-packages/scipy/linalg/_solve_toeplitz.cpython-34m.so: undefined symbol: _intel_fast_memcpy
How to fix this error in Python3?

Numpy and Scipy are popular packages. You probably can find them in Ubuntu repository. So it's better to install them with apt-get but not pip.
If you want MKL support, I would suggest anaconda - a full Python distribution with MKL and other acceleration libraries integrated such as CUDA. This will make your life easier.
https://www.continuum.io/downloads

Related

DLL load failed while importing _arpack from scipy.integrate

I am trying to import solve_ivp from scipy.intgrate
from scipy.integrate import solve_ivp as odesolver
and i got this error:
line 9, in <module>
from scipy.integrate import solve_ivp as odesolver
File "C:\ProgramData\Anaconda3\lib\site-packages\scipy\integrate\__init__.py", line 94, in <module>
from ._bvp import solve_bvp
File "C:\ProgramData\Anaconda3\lib\site-packages\scipy\integrate\_bvp.py", line 8, in <module>
from scipy.sparse.linalg import splu
File "C:\ProgramData\Anaconda3\lib\site-packages\scipy\sparse\linalg\__init__.py", line 114, in <module>
from .eigen import *
File "C:\ProgramData\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\__init__.py", line 9, in <module>
from .arpack import *
File "C:\ProgramData\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\arpack\__init__.py", line 20, in <module>
from .arpack import *
File "C:\ProgramData\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\arpack\arpack.py", line 42, in <module>
from . import _arpack
ImportError: DLL load failed while importing _arpack: The specified procedure could not be found.
i am trying to reinstall anaconda but it didn't work
i have tried to reinstall scipy using pip install but still got the error
any idea how to solve this error?
thank you in advance
This might be a wild guess but it seems anaconda has some issue with scipy.
May I suggest you the good ol' trick of reinstalling the dependencies ?
conda remove --force numpy scipy
pip install numpy scipy
They had an issue open for a while on anaconda's github, if you fancy the read.

IDE when import scipy, ImportError: DLL load failed: The specified procedure could not be found

When I use pycharm to run my code with from scipy import stats:
Importerror occurs: DLL load failed: The specified procedure could not be found.
Platform: Anaconda, python 3.7
IDE: pycharm, Microsoft VS code
Anaconda is installed in D:\Anaconda
The scipy package is installed properly. The code can be run successfully in Jupyter.
I have tried the similar questions, but no one can help. Can anybody give me some help to fix it?
I have also reinstalled Anaconda, however, it still faied.
From scipy import stats:
Traceback (most recent call last): ...from scipy import stats File
"D:\Anaconda3\lib\site-packages\scipy\stats__init__.py", line 345, in
from .stats import * File "D:\Anaconda3\lib\site-packages\scipy\stats\stats.py", line 171, in
from . import distributions File "D:\Anaconda3\lib\site-packages\scipy\stats\distributions.py", line
10, in
from ._distn_infrastructure import (entropy, rv_discrete, rv_continuous, File
"D:\Anaconda3\lib\site-packages\scipy\stats_distn_infrastructure.py",
line 24, in
from scipy import optimize File "D:\Anaconda3\lib\site-packages\scipy\optimize__init__.py", line 271,
in
from ._minimize import * File "D:\Anaconda3\lib\site-packages\scipy\optimize_minimize.py", line 21,
in
from scipy.sparse.linalg import LinearOperator File "D:\Anaconda3\lib\site-packages\scipy\sparse\linalg__init__.py", line
117, in
from .eigen import * File "D:\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen__init__.py",
line 11, in
from .arpack import * File "D:\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\arpack__init__.py",
line 22, in
from .arpack import * File "D:\Anaconda3\lib\site-packages\scipy\sparse\linalg\eigen\arpack\arpack.py",
line 45, in
from . import _arpack ImportError: DLL load failed: The specified procedure could not be found.
enter image description here
I solved it!
I think there must be something wrong in Scipy packages in Conda, so I remove all the packages related to Ski-learn, and download from "https://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy".
Choose numpy+whl Scipy ski-learn(corresponding edition) after downloading and install it by pip.

sklearn "numpy.dtype has the wrong size, try recompiling" in both pycharm and terminal

I got "numpy.dtype has the wrong size, try recompiling" in both pycharm and terminal when compiling Sci-kit learning. I've upgraded all packages(numpy, scikit to the latest), nothing works.Python version is 2.7. Please help. Appreciate!
checking for nltk
Traceback (most recent call last):
File "startup.py", line 6, in <module>
import nltk
File "/Library/Python/2.7/site-packages/nltk/__init__.py", line 128, in <module>
from nltk.chunk import *
File "/Library/Python/2.7/site-packages/nltk/chunk/__init__.py", line 157, in <module>
from nltk.chunk.api import ChunkParserI
File "/Library/Python/2.7/site-packages/nltk/chunk/api.py", line 13, in <module>
from nltk.parse import ParserI
File "/Library/Python/2.7/site-packages/nltk/parse/__init__.py", line 79, in <module>
from nltk.parse.transitionparser import TransitionParser
File "/Library/Python/2.7/site-packages/nltk/parse/transitionparser.py", line 21, in <module>
from sklearn.datasets import load_svmlight_file
File "/Library/Python/2.7/site-packages/sklearn/__init__.py", line 57, in <module>
from .base import clone
File "/Library/Python/2.7/site-packages/sklearn/base.py", line 11, in <module>
from .utils.fixes import signature
File "/Library/Python/2.7/site-packages/sklearn/utils/__init__.py", line 10, in <module>
from .murmurhash import murmurhash3_32
File "numpy.pxd", line 155, in init sklearn.utils.murmurhash (sklearn/utils/murmurhash.c:5029)
ValueError: numpy.dtype has the wrong size, try recompiling
The error "numpy.dtype has the wrong size, try recompiling" means that sklearn was compiled against a numpy more recent than the numpy version sklearn is now trying to import. To fix this, you need to make sure that sklearn is compiled against the version of numpy that it is now importing, or an earlier version. See ValueError: numpy.dtype has the wrong size, try recompiling for a detailed explanation.
I guess from your paths that you are using the OSX system Python (the one that ships with OSX, at /usr/bin/python). Apple has modified this Python in a way that makes it pick up its own version of numpy rather than any version that you install with pip etc - see https://github.com/MacPython/wiki/wiki/Which-Python#system-python-and-extra-python-packages . I strongly recommend you switch to Python.org or homebrew Python to make it easier to work with packages depending on numpy.
The problem occurs when you are using incompatible versions. Check the versions using:
pip freeze
or, for a specific module
pip freeze | grep Module_Name
I fix my problem by updating all packages:
pip install -U scikit-learn numpy scipy pandas matplotlib
As of Today(30/11/2016). These versions are compatible:
matplotlib==1.5.2
nltk==3.2.1
numpy==1.11.2
pandas==0.19.1
scikit-learn==0.18.1
scipy==0.18.1
textblob==0.11.1

ImportError: cannot import name flib

I want to use Python for trying out hddm.
I installed anaconda, Python 2.7. When I try to follow the hddm tutorial in the command line window in spyder, the following happens, which seems to be a problem in pymc:
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
import hddm
Traceback (most recent call last):
File "<ipython-input-24-17365318b31c>", line 1, in <module>
import hddm
File "/Users/c/anaconda/lib/python2.7/site-packages/hddm/__init__.py", line 7, in <module>
import likelihoods
File "/Users/c/anaconda/lib/python2.7/site-packages/hddm/likelihoods.py", line 2, in <module>
import pymc as pm
File "/Users/c/anaconda/lib/python2.7/site-packages/pymc/__init__.py", line 31, in <module>
from .distributions import *
File "/Users/c/anaconda/lib/python2.7/site-packages/pymc/distributions.py", line 30, in <module>
from . import flib, utils
ImportError: cannot import name flib
I work on Mac OS X 10.7. On the web, I find some comments concerning pymc possibly not being compiled with the correct version of gfortran, but the solutions all seem to be for windows. Also, I thought that this kind of problem should not happen with an integrated system like Anaconda?
There are two options:
use conda install -c conda.binstar.org/pymc pymc
install gfortran and use pip install -U pymc

Error importing numpy after upgrading with pip

This question is related to a question here: Unable to import numpy
I ran: sudo pip install --upgrade numpy
then when I ran python and tried to import numpy I got this strange error!!! I'm going crazy!
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/__init__.py", line 153, in <module>
from . import add_newdocs
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/lib/__init__.py", line 18, in <module>
from .polynomial import *
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/lib/polynomial.py", line 19, in <module>
from numpy.linalg import eigvals, lstsq, inv
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/linalg/__init__.py", line 50, in <module>
from .linalg import *
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/linalg/linalg.py", line 29, in <module>
from numpy.linalg import lapack_lite, _umath_linalg
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/linalg/lapack_lite.so, 2): Symbol not found: __gfortran_compare_string
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/linalg/lapack_lite.so
Expected in: flat namespace
in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/linalg/lapack_lite.so
>>>
EDIT:
I also ran this:
$ pip show numpy
---
Name: numpy
Version: 1.8.0
Location: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
Requires:
The fix for me to was to manually install gcc via macports:
sudo port install gcc48
... which installs gfortran, but without the alias that numpy seems to be expecting (gfortran). Then we make a symlink:
sudo ln -s /opt/local/bin/gfortran-mp-4.8 /opt/local/bin/gfortran
After that, I uninstalled and reinstalled numpy via pip and it works like a charm.
This fixed the issue for me on mavericks last night. From what I've read, gfortran used to be part of the OS X command line tools, but isn't as of Lion or so. Installing gcc separately "fixes" that.

Categories

Resources