我目前正在与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:\users\james\appdata\local\programs\python\python37\lib\site-packages\sklearn\__init__.py in <module>
63 from . import __check_build
---> 64 from .base import clone
65 from .utils._show_versions import show_versions
c:\users\james\appdata\local\programs\python\python37\lib\site-packages\sklearn\base.py in <module>
12 from .externals import six
---> 13 from .utils.fixes import signature
14 from . import __version__
c:\users\james\appdata\local\programs\python\python37\lib\site-packages\sklearn\utils\__init__.py in <module>
15 from ..exceptions import DataConversionWarning
---> 16 from .fixes import _Sequence as Sequence
17 from .deprecation import deprecated
c:\users\james\appdata\local\programs\python\python37\lib\site-packages\sklearn\utils\fixes.py in <module>
84 else:
---> 85 from scipy.special import boxcox # noqa
86
c:\users\james\appdata\local\programs\python\python37\lib\site-packages\scipy\special\__init__.py in <module>
640
--> 641 from ._ufuncs import *
642
ImportError: DLL load failed: The specified module could not be found.
我使用pip install来获取sklearn,在cmd中执行pip list时,它就在那里。但是,当我什至尝试导入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:\Users\James\AppData\Local\Programs\Python\Python37\lib\site-packages
中
我的文件url中的大写字母是引起这种情况的原因还是与路径本身有关?
答案 0 :(得分:0)
如果,您已经具有 numpy 和 scipy 的有效安装,则请执行以下操作:
pip install -U scikit-learn
否则:
conda install scikit-learn
最后检查更新:
conda update pip
答案 1 :(得分:0)
在Jupyter笔记本内部使用点子
!{sys.executable} -m pip install -U scikit-learn
这将使用sys.executable
为您当前的内核运行正确的点,而不是为其他一些Python安装。