2

I'm dealing with the following error with importing keras library:

>>> import keras

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-7-c74e2bd4ca71> in <module>()
----> 1 import keras

/usr/local/lib/python3.6/dist-packages/keras/__init__.py in <module>()
      1 from __future__ import absolute_import
      2 
----> 3 from . import utils
      4 from . import activations
      5 from . import applications

/usr/local/lib/python3.6/dist-packages/keras/utils/__init__.py in <module>()
     24 from .layer_utils import get_source_inputs
     25 from .layer_utils import print_summary
---> 26 from .vis_utils import model_to_dot
     27 from .vis_utils import plot_model
     28 from .np_utils import to_categorical

/usr/local/lib/python3.6/dist-packages/keras/utils/vis_utils.py in <module>()
      5 
      6 import os
----> 7 from ..models import Model
      8 from ..layers.wrappers import Wrapper
      9 

/usr/local/lib/python3.6/dist-packages/keras/models.py in <module>()
     10 from .engine.input_layer import Input
     11 from .engine.input_layer import InputLayer
---> 12 from .engine.training import Model
     13 from .engine.sequential import Sequential
     14 from .engine.saving import save_model

/usr/local/lib/python3.6/dist-packages/keras/engine/__init__.py in <module>()
      6 from .base_layer import Layer
      7 from .network import get_source_inputs
----> 8 from .training import Model

/usr/local/lib/python3.6/dist-packages/keras/engine/training.py in <module>()
     13 from .base_layer import Layer
     14 from . import training_utils
---> 15 from . import training_arrays
     16 from . import training_generator
     17 from .. import backend as K

/usr/local/lib/python3.6/dist-packages/keras/engine/training_arrays.py in <module>()
      6 
      7 import numpy as np
----> 8 from scipy.sparse import issparse
      9 
     10 from .training_utils import batch_shuffle

/usr/lib/python3/dist-packages/scipy/sparse/__init__.py in <module>()
    212 
    213 from .base import *
--> 214 from .csr import *
    215 from .csc import *
    216 from .lil import *

/usr/lib/python3/dist-packages/scipy/sparse/csr.py in <module>()
     11 from scipy._lib.six import xrange
     12 
---> 13 from ._sparsetools import csr_tocsc, csr_tobsr, csr_count_blocks, \
     14         get_csr_submatrix, csr_sample_values
     15 from .sputils import (upcast, isintlike, IndexMixin, issequence,

ModuleNotFoundError: No module named 'scipy.sparse._sparsetools'

I've also checked these posts (QA-1, QA-2), but the problem still remains.


[NOTE]:

Python version: 3.6.9 Numpy version: 1.17.1 Keras version: 2.3.0
Scipy version: 0.17.0
OS: Ubuntu 16.04

  • Guys, I don't want to use conda instead of pip
Benyamin Jafari
  • 27,880
  • 26
  • 135
  • 150

1 Answers1

4

SciPy requires the following software installed for your platform:

Python >= 3.5 NumPy >= 1.13.3

update the libraries for 3.6

https://github.com/scipy/scipy/blob/master/INSTALL.rst.txt#linux

OR ELSE

According to from ._sparsetools import csr_tocsc, csr_tobsr, csr_count_blocks, \ImportError: DLL load failed: The specified module could not be found

Update your C++ redistributable compiler.

OR ELSE

Reinstall scipy using:

pip uninstall scipy
pip install scipy
  • 1
    Thanks for the response, I tried the third manner with success, but I couldn't remove `keras` package by `pip` because I think I installed the `keras` package by `apt` in last time, so I removed it by this command: `apt-get remove python3-keras` then reinstalled it by `pip3 install scipy` as well. +1 – Benyamin Jafari Oct 04 '19 at 06:10