我目前正在使用Jupyter编写我的第一个程序。当我运行一个单元格时,我会收到以下
<ipython-input-6-7a7db0de4539> in <module>
1 try:
----> 2 from sklearn.datasets import fetch_openml
3 mnist = fetch_openml('mnist_784', version=1, cache=True)
c:usersjamesappdatalocalprogramspythonpython37libsite-packagessklearn__init__.py in <module>
63 from . import __check_build
---> 64 from .base import clone
65 from .utils._show_versions import show_versions
c:usersjamesappdatalocalprogramspythonpython37libsite-packagessklearnbase.py in <module>
12 from .externals import six
---> 13 from .utils.fixes import signature
14 from . import __version__
c:usersjamesappdatalocalprogramspythonpython37libsite-packagessklearnutils__init__.py in <module>
15 from ..exceptions import DataConversionWarning
---> 16 from .fixes import _Sequence as Sequence
17 from .deprecation import deprecated
c:usersjamesappdatalocalprogramspythonpython37libsite-packagessklearnutilsfixes.py in <module>
84 else:
---> 85 from scipy.special import boxcox # noqa
86
c:usersjamesappdatalocalprogramspythonpython37libsite-packagesscipyspecial__init__.py in <module>
640
--> 641 from ._ufuncs import *
642
ImportError: DLL load failed: The specified module could not be found.
我使用pip安装来获得sklearn,当在cmd中执行pip列表时,它就在那里。然而,当我尝试导入sklearn时,我会遇到一个错误。
我已经检查了import sys
和sys.path
,这给了我:
'C:\Users\James\Documents\Machine Learning Comp Vision\Project 1',
'C:\Users\James\Documents\Machine Learning Comp Vision\Project 1',
'c:\users\james\appdata\local\programs\python\python37\python37.zip',
'c:\users\james\appdata\local\programs\python\python37\DLLs',
'c:\users\james\appdata\local\programs\python\python37\lib',
'c:\users\james\appdata\local\programs\python\python37',
'',
'c:\users\james\appdata\local\programs\python\python37\lib\site-packages',
'c:\users\james\appdata\local\programs\python\python37\lib\site-packages\IPython\extensions',
'C:\Users\James\.ipython']
我的所有模块都位于C:UsersJamesAppDataLocalProgramsPythonPython37libsite-packages
中我的文件url中的大写字母是造成这种情况的原因吗?还是与路径本身有关?
如果您已经安装了numpy和scipy,请执行以下操作:
pip install -U scikit-learn
否则:
conda install scikit-learn
最后检查更新:
conda update pip
使用Jupyter笔记本内部的pip
!{sys.executable} -m pip install -U scikit-learn
这将使用sys.executable
为当前内核运行正确的pip,而不是为其他Python安装运行。