尝试在 Python 3.8 上安装 Sklearn 时出错

Trying to Install Sklearn on Python 3.8 Gives an Error

我正在尝试使用以下方法在 Python 3.8 和 Windows 10 上安装 sklearn (scikit-learn):

pip install sklearn

我也用过:

pip3 install sklearn

pip install scikit-learn 

pip install -U scikit-learn 

以及:

pip install --only-binary :all: sklearn

我也试过升级 pip/setuptools。

有一大段错误;其中,似乎相关的部分提到了Fortran:

  customize GnuFCompiler
  Could not locate executable g77
  Could not locate executable f77
  customize IntelVisualFCompiler
  Could not locate executable ifort
  Could not locate executable ifl
  customize AbsoftFCompiler
  Could not locate executable f90
  customize CompaqVisualFCompiler
  Could not locate executable DF
  customize IntelItaniumVisualFCompiler
  Could not locate executable efl
  customize Gnu95FCompiler
  Could not locate executable gfortran
  Could not locate executable f95
  customize G95FCompiler
  Could not locate executable g95
  customize IntelEM64VisualFCompiler
  customize IntelEM64TFCompiler
  Could not locate executable efort
  Could not locate executable efc
  customize PGroupFlangCompiler
  Could not locate executable flang
  don't know how to compile Fortran code on platform 'nt'
    NOT AVAILABLE

另一部分错误:

No module named 'numpy.distutils._msvccompiler' in numpy.distutils;

我只是想知道这是不是因为 3.8 的新特性?是否有任何人都知道的解决方法?

它似乎围绕着 NumPy。我已经卸载了那个软件包并重新安装了它。

刚刚发现 GitHub issue 说了以下内容(16 天前):

Python 3.8 is not officially supported by NumPy yet. We strongly suggest you stick with python 3.7 for now, until you see a 3.8 designation in the "Programming Language" section of the PyPI numpy page (probably several weeks) or until an Anaconda release with Python 3.8 is available (probably several months)

所以它看起来可能是底层依赖项还不能与 3.8 一起使用。实际上,上周我在另一个包裹上遇到了类似的问题。如果你得到 3.7.5 install,你可能会很幸运。确保您获得正确的平台(32 位为 x86,64 位为 x64)并确保选中复选框以将其添加到您的路径中。

我猜你在 Windows 是吗?如果是这样,那么在安装后打开一个 powershell 并输入 gcm pythongcm pip 以确保它们是从 3.7 安装中提取的。如果没有,您必须在系统环境变量中编辑 PATH,并将新的 Python37 目录移动到您的 PATH 中的 Python38 之前。

希望能解决问题![​​=15=]

尝试运行pip install --pre -f https://sklearn-nightly.scdn8.secure.raxcdn.com scikit-learn。它对我有用。

在命令提示符下试试这个:

py -m pip install -U scikit-learn