【问题标题】:OSError: [WinError 126] The specified module could not be found in PythonOSError: [WinError 126] 在 Python 中找不到指定的模块
【发布时间】:2020-10-24 07:37:15
【问题描述】:

我正在尝试导入以下库。导入 sklearn 时收到错误消息。我相信它与 DLL 路径有关,但我无法纠正它。我不想在代码中手动指定任何路径。请帮忙

代码:

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

from sklearn import preprocessing
%matplotlib inline

错误:

OSError                                   Traceback (most recent call last)
<ipython-input-3-c2a7628c052c> in <module>
      3 import matplotlib.pyplot as plt
      4 
----> 5 from sklearn import preprocessing
      6 get_ipython().run_line_magic('matplotlib', 'inline')

~\anaconda3\lib\site-packages\sklearn\__init__.py in <module>
     62 else:
     63     from . import __check_build
---> 64     from .base import clone
     65     from .utils._show_versions import show_versions
     66 

~\anaconda3\lib\site-packages\sklearn\base.py in <module>
     10 
     11 import numpy as np
---> 12 from scipy import sparse
     13 from .externals import six
     14 from .utils.fixes import signature

~\anaconda3\lib\site-packages\scipy\__init__.py in <module>
    102 
    103 # Allow distributors to run custom init code
--> 104 from . import _distributor_init
    105 
    106 __all__ += _num.__all__

~\anaconda3\lib\site-packages\scipy\_distributor_init.py in <module>
     59             os.chdir(libs_path)
     60             for filename in glob.glob(os.path.join(libs_path, '*dll')):
---> 61                 WinDLL(os.path.abspath(filename))
     62         finally:
     63             os.chdir(owd)

~\anaconda3\lib\ctypes\__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error)
    362 
    363         if handle is None:
--> 364             self._handle = _dlopen(self._name, mode)
    365         else:
    366             self._handle = handle

OSError: [WinError 126] The specified module could not be found

【问题讨论】:

  • 您是通过终端还是 IDE 运行代码?如果您在终端中运行代码,请确保您已激活环境。

标签: python python-3.x numpy error-handling scikit-learn


【解决方案1】:

您可以尝试卸载 scipy,然后重新安装此特定版本。正如这个特定的 github 问题线程中所述,新版本的 scipy 存在问题。

pip uninstall scipy
pip install scipy==1.4.1

https://github.com/ultralytics/yolov5/issues/241

【讨论】:

    猜你喜欢
    • 2020-10-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-23
    • 2020-08-19
    • 1970-01-01
    • 2021-09-03
    相关资源
    最近更新 更多