gpt4 book ai didi

python - 导入错误:没有名为 scipy.sparse 的模块

转载 作者:太空宇宙 更新时间:2023-11-04 06:40:20 26 4
gpt4 key购买 nike

我使用以下命令在 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'

最佳答案

scipy 路径混淆了。卸载

pip uninstall scipy

使用 conda 安装对我有用

conda install scipy

关于python - 导入错误:没有名为 scipy.sparse 的模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55043789/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com