ModuleNotFoundError: No module named 'scipy.linalg' - python

Bit confused, as the scipy package is installed, but still get
from sklearn.model_selection import train_test_split
File "/home/jct/gpu_ready/lib/python3.6/site-packages/sklearn/__init__.py", line 76, in <module>
from .base import clone
File "/home/jct/gpu_ready/lib/python3.6/site-packages/sklearn/base.py", line 16, in <module>
from .utils import _IS_32BIT
File "/home/jct/gpu_ready/lib/python3.6/site-packages/sklearn/utils/__init__.py", line 20, in <module>
from .validation import (as_float_array,
File "/home/jct/gpu_ready/lib/python3.6/site-packages/sklearn/utils/validation.py", line 21, in <module>
from .fixes import _object_dtype_isnan
File "/home/jct/gpu_ready/lib/python3.6/site-packages/sklearn/utils/fixes.py", line 18, in <module>
from scipy.sparse.linalg import lsqr as sparse_lsqr # noqa
File "/home/jct/gpu_ready/lib/python3.6/site-packages/scipy/sparse/linalg/__init__.py", line 113, in <module>
from .isolve import *
File "/home/jct/gpu_ready/lib/python3.6/site-packages/scipy/sparse/linalg/isolve/__init__.py", line 8, in <module>
from .lgmres import lgmres
File "/home/jct/gpu_ready/lib/python3.6/site-packages/scipy/sparse/linalg/isolve/lgmres.py", line 10, in <module>
from scipy.linalg import get_blas_funcs, get_lapack_funcs
ModuleNotFoundError: No module named 'scipy.linalg'
Also
$ pip3 show scipy
Name: scipy
Version: 1.4.1
Summary: SciPy: Scientific Library for Python
Home-page: https://www.scipy.org
Author: None
Author-email: None
License: BSD
Location: /home/jct/gpu_ready/lib/python3.6/site-packages
Requires: numpy

Related

AttributeError: 'module' object has no attribute 'computation'

Im trying to use Keras (Sequential) but I get the following error when I try to import it:
File "kaggle_titanic_keras.py", line 3, in <module>
from keras.models import Sequential
File "/anaconda/lib/python2.7/site-packages/keras/__init__.py", line 4, in <module>
from . import applications
File "/anaconda/lib/python2.7/site-packages/keras/applications/__init__.py", line 1, in <module>
from .vgg16 import VGG16
File "/anaconda/lib/python2.7/site-packages/keras/applications/vgg16.py", line 14, in <module>
from ..models import Model
File "/anaconda/lib/python2.7/site-packages/keras/models.py", line 14, in <module>
from . import layers as layer_module
File "/anaconda/lib/python2.7/site-packages/keras/layers/__init__.py", line 4, in <module>
from ..engine import Layer
File "/anaconda/lib/python2.7/site-packages/keras/engine/__init__.py", line 8, in <module>
from .training import Model
File "/anaconda/lib/python2.7/site-packages/keras/engine/training.py", line 24, in <module>
from .. import callbacks as cbks
File "/anaconda/lib/python2.7/site-packages/keras/callbacks.py", line 25, in <module>
from tensorflow.contrib.tensorboard.plugins import projector
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/__init__.py", line 30, in <module>
from tensorflow.contrib import factorization
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/factorization/__init__.py", line 24, in <module>
from tensorflow.contrib.factorization.python.ops.gmm import *
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/factorization/python/ops/gmm.py", line 27, in <module>
from tensorflow.contrib.learn.python.learn.estimators import estimator
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/learn/__init__.py", line 87, in <module>
from tensorflow.contrib.learn.python.learn import *
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/learn/python/__init__.py", line 23, in <module>
from tensorflow.contrib.learn.python.learn import *
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/__init__.py", line 25, in <module>
from tensorflow.contrib.learn.python.learn import estimators
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/estimators/__init__.py", line 297, in <module>
from tensorflow.contrib.learn.python.learn.estimators.dnn import DNNClassifier
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/estimators/dnn.py", line 29, in <module>
from tensorflow.contrib.learn.python.learn.estimators import dnn_linear_combined
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/estimators/dnn_linear_combined.py", line 31, in <module>
from tensorflow.contrib.learn.python.learn.estimators import estimator
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/estimators/estimator.py", line 49, in <module>
from tensorflow.contrib.learn.python.learn.learn_io import data_feeder
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/learn_io/__init__.py", line 21, in <module>
from tensorflow.contrib.learn.python.learn.learn_io.dask_io import extract_dask_data
File "/anaconda/lib/python2.7/site-packages/tensorflow/contrib/learn/python/learn/learn_io/dask_io.py", line 26, in <module>
import dask.dataframe as dd
File "/anaconda/lib/python2.7/site-packages/dask/dataframe/__init__.py", line 3, in <module>
from .core import (DataFrame, Series, Index, _Frame, map_partitions,
File "/anaconda/lib/python2.7/site-packages/dask/dataframe/core.py", line 38, in <module>
pd.computation.expressions.set_use_numexpr(False)
AttributeError: 'module' object has no attribute 'computation'
Im running Python 2.7, TensorFlow 1.1 , Keras 2.0.3 and 'upgraded' to Pandas 0.20.1 yesterday which I suspect is causing the problem but the error message says nothing about it.
Update dask to 0.15.0 will solve the issue
update cmd: conda update dask
input pip show dask will show follow message
Name: dask
Version: 0.15.0
Summary: Parallel PyData with Task Scheduling
Home-page: http://github.com/dask/dask/
Author: Matthew Rocklin
Author-email: mrocklin#gmail.com
License: BSD
Location: c:\anaconda3\lib\site-packages
Requires:
dask-0.14.3 works and eliminates the import error
I reverted back to Pandas 0.19.2 and it resolved this problem.
The full command I use is
conda install pandas=0.19.2
and answer y to downgrade the pandas and it worked now.
I had installed below versions:
python 3.5
tensorflow 1.2.1
pandas 0.21
dask 0.15.3
and was getting the following error:
pd.core.computation.expressions.set_use_numexpr(False)
AttributeError: 'module' object has no attribute 'expressions'
I downgraded to pandas 0.19.2 and dask 0.15.0 and the python script worked fine!

Error while importing matplotlib.pyplot Python

I have a problem while importing matplotlib.pyplot , I have python2.7 windows 7 64bits
>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
File "<pyshell#16>", line 1, in <module>
import matplotlib.pyplot as plt
File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 129, in <module>
from matplotlib.cbook import is_string_like
File "C:\Python27\lib\site-packages\matplotlib\cbook.py", line 28, in <module>
import numpy as np
File "C:\Python27\lib\site-packages\numpy\__init__.py", line 180, in <module>
from . import add_newdocs
File "C:\Python27\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Python27\lib\site-packages\numpy\lib\__init__.py", line 4, in <module>
from type_check import *
File "C:\Python27\lib\site-packages\numpy\lib\type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "C:\Python27\lib\site-packages\numpy\core\__init__.py", line 20, in <module>
import function_base
File "C:\Python27\lib\site-packages\numpy\core\function_base.py", line 6, in <module>
from .numeric import result_type, NaN, shares_memory, MAY_SHARE_BOUNDS, TooHardError
ImportError: cannot import name shares_memory
Please help
I soled the issue by uninstalling python27, reinstall it again and install extension
pip install matplotlib-1.5.0-cp27-none-win_amd64.whl
this will install automaticaly numpy extension

I get ImportError: libpng16.so.16 only in virtualenv (ubuntu 14.04, python 2.7.6)

While using matplotlib.pyplot in python interpreter in virtual environment I get this error :
>>> import matplotlib.pyplot as a
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/haz/Envs/DataVizProj/local/lib/python2.7/site-packages/matplotlib/pyplot.py", line 29, in <module>
import matplotlib.colorbar
File "/home/haz/Envs/DataVizProj/local/lib/python2.7/site-packages/matplotlib/colorbar.py", line 34, in <module>
import matplotlib.collections as collections
File "/home/haz/Envs/DataVizProj/local/lib/python2.7/site-packages/matplotlib/collections.py", line 27, in <module>
import matplotlib.backend_bases as backend_bases
File "/home/haz/Envs/DataVizProj/local/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 62, in <module>
import matplotlib.textpath as textpath
File "/home/haz/Envs/DataVizProj/local/lib/python2.7/site-packages/matplotlib/textpath.py", line 18, in <module>
from matplotlib.mathtext import MathTextParser
File "/home/haz/Envs/DataVizProj/local/lib/python2.7/site-packages/matplotlib/mathtext.py", line 60, in <module>
import matplotlib._png as _png
ImportError: libpng16.so.16: cannot open shared object file: No such file or directory
I have already installed ZLIB , FREETYPE , LIBPNG for matplotlib and I
only get this error in virtualenv.I am a beginner and following this tutorial.
Btw I don't use anaconda or canopy .Just python2.7

python x86 ImportError: DLL load failed

I have system with win7 x64 and code which worked well before with Anaconda2-2.4.0-Windows-x86
from sklearn.linear_model import LinearRegression
But now I get:
File "C:\Anaconda2\lib\site-packages\sklearn\linear_model\__init__.py", line 1
2, in <module>
from .base import LinearRegression
File "C:\Anaconda2\lib\site-packages\sklearn\linear_model\base.py", line 28, i
n <module>
from ..utils import as_float_array, check_array, check_X_y
File "C:\Anaconda2\lib\site-packages\sklearn\utils\__init__.py", line 16, in <
module>
from .class_weight import compute_class_weight, compute_sample_weight
File "C:\Anaconda2\lib\site-packages\sklearn\utils\class_weight.py", line 7, i
n <module>
from ..utils.fixes import in1d
File "C:\Anaconda2\lib\site-packages\sklearn\utils\fixes.py", line 318, in <mo
dule>
from scipy.sparse.linalg import lsqr as sparse_lsqr
File "C:\Anaconda2\lib\site-packages\scipy\sparse\linalg\__init__.py", line 11
3, in <module>
from .matfuncs import *
File "C:\Anaconda2\lib\site-packages\scipy\sparse\linalg\matfuncs.py", line 19
, in <module>
import scipy.misc
File "C:\Anaconda2\lib\site-packages\scipy\misc\__init__.py", line 49, in <mod
ule>
from scipy.special import comb, factorial, factorial2, factorialk
File "C:\Anaconda2\lib\site-packages\scipy\special\__init__.py", line 601, in
<module>
from ._ufuncs import *
ImportError: DLL load failed: The specified procedure could not be found.
Yesterday, I have installed software which brings some python with itself and look like does something else during installation.
In Dependency walker I see following picture:
I have installed Anaconda2-2.4.0-Windows-x86_64 and in this python version all works fine.
Could you please help me to understand what has been changed in system and how I can fix it?(I have completely remove installed software but it does not help)

Python 2.7 & PyDev - matplotlib and NumPy not working

I am trying to get matplotlib to work under Windows 7 (64-bit) using Python 2.7 and Eclipse with the PyDev plugin . I installed NumPy from http://www.lfd.uci.edu/~gohlke/pythonlibs/.
The problem is when I write the following code in Eclipse:
import matplotlib.pyplot as plt
plt.figure()
I get the following error:
Traceback (most recent call last):
File "C:\Users\davedove\Documents\eclipseWorkspace\python.graphExample\example.py", line 1, in <module>
import matplotlib.pyplot as plt
File "C:\Python27\lib\site-packages\matplotlib\__init__.py", line 104, in <module>
import os, re, shutil, subprocess, sys, warnings
File "C:\Python27\lib\shutil.py", line 12, in <module>
import collections
File "C:\Python27\Lib\site-packages\matplotlib\collections.py", line 12, in <module>
import numpy as np
File "C:\Python27\lib\site-packages\numpy\__init__.py", line 147, in <module>
import add_newdocs
File "C:\Python27\lib\site-packages\numpy\add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "C:\Python27\lib\site-packages\numpy\lib\__init__.py", line 4, in <module>
from type_check import *
File "C:\Python27\lib\site-packages\numpy\lib\type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "C:\Python27\lib\site-packages\numpy\core\__init__.py", line 40, in <module>
from numpy.testing import Tester
File "C:\Python27\lib\site-packages\numpy\testing\__init__.py", line 8, in <module>
from unittest import TestCase
File "C:\Python27\lib\unittest\__init__.py", line 58, in <module>
from .result import TestResult
File "C:\Python27\lib\unittest\result.py", line 9, in <module>
from . import util
File "C:\Python27\lib\unittest\util.py", line 2, in <module>
from collections import namedtuple, OrderedDict
ImportError: cannot import name namedtuple
Also with NumPy when I write the following code in Eclipse:
import numpy
add(array([-1.2, 1.2]), array([1,3]))
I get the following error:
Traceback (most recent call last):
File "C:\Users\davedove\Documents\eclipseWorkspace\python.graphExample\example.py", line 1, in <module>
import numpy
File "C:\Python27\lib\site-packages\numpy\__init__.py", line 147, in <module>
import add_newdocs
File "C:\Python27\lib\site-packages\numpy\add_newdocs.py", line 9, in <module>
from numpy.lib import add_newdoc
File "C:\Python27\lib\site-packages\numpy\lib\__init__.py", line 4, in <module>
from type_check import *
File "C:\Python27\lib\site-packages\numpy\lib\type_check.py", line 8, in <module>
import numpy.core.numeric as _nx
File "C:\Python27\lib\site-packages\numpy\core\__init__.py", line 40, in <module>
from numpy.testing import Tester
File "C:\Python27\lib\site-packages\numpy\testing\__init__.py", line 8, in <module>
from unittest import TestCase
File "C:\Python27\lib\unittest\__init__.py", line 58, in <module>
from .result import TestResult
File "C:\Python27\lib\unittest\result.py", line 9, in <module>
from . import util
File "C:\Python27\lib\unittest\util.py", line 2, in <module>
from collections import namedtuple, OrderedDict
File "C:\Python27\Lib\site-packages\matplotlib\collections.py", line 13, in <module>
import numpy.ma as ma
File "C:\Python27\lib\site-packages\numpy\ma\__init__.py", line 44, in <module>
import core
File "C:\Python27\lib\site-packages\numpy\ma\core.py", line 73, in <module>
from numpy import ndarray, amax, amin, iscomplexobj, bool_
ImportError: cannot import name ndarray
From the command line both NumPy & matplotlib both run fine, I have added both matplotlib and NumPy from preferences -> pydev -> interpreter python. What could be the problem? Also what alternative could I use to create graphs using Python?
Works for me. Very probably you have added matplotlib and numpy directories to your PYTHONPATH, such that matplotlib.collections is imported instead of the collections module from the Python standard library. Try remove matplotlib and numpy directories from the PYTHONPATH in the Eclipse > PyDev > Python interpreter settings.
I was having the same issue, but follow the instructions at the bottom of the page and installed the SciPy SuperPack. Worked like a charm on Mountain Lion:
https://github.com/fonnesbeck/ScipySuperpack
After it installs numpy you can always just ctrl-C out of the other packages

Categories

Resources