我正在尝试导入 sklearn,但是当我尝试这样做时,我收到以下信息:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-2-8fd979e02004> in <module>()
----> 1 import sklearn
C:\Users\Alpine\AppData\Local\Enthought\Canopy\User\sklearn__init__.py in <module>()
29 # process, as it may not be compiled yet
30 else:
---> 31 from . import __check_build
32 from .base import clone
33
C:\Users\Alpine\AppData\Local\Enthought\Canopy\User\sklearn__check_build__init__.py in <module>()
44 from ._check_build import check_build
45 except ImportError as e:
---> 46 raise_build_error(e)
C:\Users\Alpine\AppData\Local\Enthought\Canopy\User\sklearn__check_build__init__.py in raise_build_error(e)
39 to build the package before using it: run `python setup.py install` or
40 `make` in the source directory.
---> 41 %s""" % (e, local_dir, ''.join(dir_content).strip(), msg))
42
43 try:
ImportError: No module named _check_build
___________________________________________________________________________
Contents of C:\Users\Alpine\AppData\Local\Enthought\Canopy\User\sklearn__check_build:
setup.py setup.pyc _check_build.c
_check_build.pyx __init__.py __init__.pyc
___________________________________________________________________________
It seems that scikit-learn has not been built correctly.
If you have installed scikit-learn from source, please do not forget
to build the package before using it: run `python setup.py install` or
`make` in the source directory.
If you have used an installer, please check that it is suited for your
Python version, your operating system and your platform.
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line string', (1, 2))
我相当确定 scikit-learn 已正确构建,因为我成功运行了 python setup.py install
没有任何事故。但是我确实尝试运行 python setup.py bdist_wininst -b doc/logos/scikit-learn-logo.bmp
尽管在 error: cannot copy tree 'build\scripts.win-amd64-2.7': not a directory
被打断了。
可能有人知道如何解决这个问题吗?
原文由 Alpine 发布,翻译遵循 CC BY-SA 4.0 许可协议
我在 Windows 10 上遇到了同样的问题。我用 Python 3.7 安装了 Anaconda,这个安装不仅解决了这个问题。要解决在 anaconda 提示符下运行:
至少这对我有用