0

我正在使用 Visual Studio,并且正在尝试学习如何使用 scikit-learn/sklearn。我使用“pip”安装了它和所有其他软件包,没有任何问题。

我实际上只是想导入它。还没有其他代码。

每当我尝试导入它时,我都会收到以下错误:

Traceback (most recent call last):
File "c:/Users/samir/Code/Machine Learning A-Z/Machine Learning A-Z (Codes and Datasets)/Part 1 - Data Preprocessing/Section 2 Part 1 - Data Preprocessing/Python/data_preprocessing_Samir.py", line 20, in <module>
    import sklearn
  File "C:\Users\samir\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\sklearn\__init__.py", line 82, in <module>
    from .base import clone
  File "C:\Users\samir\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\sklearn\base.py", line 17, in <module>
    from .utils import _IS_32BIT
  File "C:\Users\samir\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\sklearn\utils\__init__.py", line 20, in <module>
    from scipy.sparse import issparse
  File "C:\Users\samir\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\scipy\__init__.py", line 130, in <module>
    from . import _distributor_init
  File "C:\Users\samir\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\scipy\_distributor_init.py", line 61, in <module>
    WinDLL(os.path.abspath(filename))
  File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.7_3.7.2544.0_x64__qbz5n2kfra8p0\lib\ctypes\__init__.py", line 364, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
4

1 回答 1

0

您需要 openslide windows 库。使用以下任一链接获取二进制文件。

32位:https ://github.com/openslide/openslide-winbuild/releases/download/v20171122/openslide-win32-20171122.zip

64位:https ://github.com/openslide/openslide-winbuild/releases/download/v20171122/openslide-win64-20171122.zip

安装后,打开你安装到的目录,找到“bin”文件夹并将其添加到你的windows路径。

要将“bin”文件夹的路径添加到 Path 变量中,请启动“运行”框并输入“sysdm.cpl”

在此处输入图像描述

这应该会打开“系统属性”窗口。转到“高级”选项卡,然后单击“环境变量”按钮:

在此处输入图像描述

在“系统变量”窗口中,找到“路径”变量并单击编辑:

在此处输入图像描述

将光标定位在变量值行的末尾,然后添加到 python.exe 文件的路径,并以分号字符 (;) 开头。在我们的示例中,我们添加了以下值:;C:\Python34。(但对你来说,添加 openslide “bin” 文件夹)

在此处输入图像描述

关闭所有窗户。现在您可以运行 sklearn。

于 2021-06-18T14:53:06.260 回答