我使用以下命令在Ubuntu上安装了Scipy:
sudo apt-get install python-scipy
pip install scipy
但是当我运行导入操作时,出现了以下错误:
ImportError: No module named scipy.sparse
我搜索并尝试了以下方法,并重新安装了Scipy:
sudo apt-get purge python-scipy
但仍然收到相同的错误信息。
更新:我在我的 Python 文件中没有导入 Scipy,只导入了 Keras。
以下是错误信息:
(my_env) .. $ python test.py
Using TensorFlow backend.
Traceback (most recent call last):
File "test.py", line 10, in <module>
import keras
File "/home/ ../my_env/lib/python3.5/site-packages/keras/__init__.py", line 3, in <module>
from . import utils
File "/home/ ../my_env/lib/python3.5/site-packages/keras/utils/__init__.py", line 27, in <module>
from .multi_gpu_utils import multi_gpu_model
File "/home/ ../my_env/lib/python3.5/site-packages/keras/utils/multi_gpu_utils.py", line 7, in <module>
from ..layers.merge import concatenate
File "/home/ ../my_env/lib/python3.5/site-packages/keras/layers/__init__.py", line 4, in <module>
from ..engine.base_layer import Layer
File "/home/ ../my_env/lib/python3.5/site-packages/keras/engine/__init__.py", line 8, in <module>
from .training import Model
File "/home/ ../my_env/lib/python3.5/site-packages/keras/engine/training.py", line 21, in <module>
from . import training_arrays
File "/home/../my_env/lib/python3.5/site-packages/keras/engine/training_arrays.py", line 8, in <module>
from scipy.sparse import issparse
ImportError: No module named 'scipy.sparse'