gpt4 book ai didi

python - 导入sklearn时出错

转载 作者:太空宇宙 更新时间:2023-11-03 16:42:53 26 4
gpt4 key购买 nike

使用 pip install -U scikit-learn 安装 scikit-learn 后,我无法调用 import sklearn:

>>> import sklearn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python27\lib\site-packages\sklearn\__init__.py", line 57, in <module>
from .base import clone
File "C:\Python27\lib\site-packages\sklearn\base.py", line 9, in <module>
from scipy import sparse
File "C:\Python27\lib\site-packages\scipy\sparse\__init__.py", line 214, in <module>
from .csr import *
File "C:\Python27\lib\site-packages\scipy\sparse\csr.py", line 13, in <module>
from ._sparsetools import csr_tocsc, csr_tobsr, csr_count_blocks, \
ImportError: DLL load failed: %1 is not a valid Win32 application.

如何克服这个错误?

最佳答案

您可以尝试使用 Anaconda 创建虚拟环境,然后通过 conda 而不是 pip 安装 sklearn

https://uoa-eresearch.github.io/eresearch-cookbook/recipe/2014/11/20/conda/ http://conda.pydata.org/docs/using/pkgs.html#install-a-package

conda create -n yourenvname python=3.5 anaconda
conda install -n yourenvname sklearn

关于python - 导入sklearn时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36630213/

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