在Google Colab中直接从Github安装Sk-learn(scikit-learn)失败

3
我正在使用谷歌协同平台,似乎已经内置了sk-learn,因为您只需要导入TSNE模块 from sklearn.manifold import TSNE 我已经从他们的Github中fork了一个sklearn版本,并尝试安装它,但是安装失败。为了隔离问题,我只是尝试直接从Github安装sk-learn,并找出为什么无法安装的原因。
这是我使用的代码。
!pip install https://github.com/scikit-learn/scikit-learn/archive/master.zip

这里是输出结果

Collecting https://github.com/Santosh-Gupta/scikit-learn/archive/master.zip
  Downloading https://github.com/Santosh-Gupta/scikit-learn/archive/master.zip (6.6MB)
    100% |████████████████████████████████| 6.6MB 3.8MB/s 
Requirement already satisfied: numpy>=1.8.2 in /usr/local/lib/python3.6/dist-packages (from scikit-learn==0.20.dev0) (1.14.5)
Requirement already satisfied: scipy>=0.13.3 in /usr/local/lib/python3.6/dist-packages (from scikit-learn==0.20.dev0) (0.19.1)
Building wheels for collected packages: scikit-learn
  Running setup.py bdist_wheel for scikit-learn ... error
  Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-req-build-j3idof1a/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-wvc5lddz --python-tag cp36:
  Partial import of sklearn during the build process.
  blas_opt_info:
  blas_mkl_info:
  customize UnixCCompiler
    libraries mkl_rt not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu']
    NOT AVAILABLE

  blis_info:
  customize UnixCCompiler
    libraries blis not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu']
    NOT AVAILABLE

  openblas_info:
  customize UnixCCompiler
  customize UnixCCompiler
    libraries openblas not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu']
    NOT AVAILABLE

  atlas_3_10_blas_threads_info:
  Setting PTATLAS=ATLAS
  customize UnixCCompiler
    libraries tatlas not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu/atlas', '/usr/lib/x86_64-linux-gnu']
    NOT AVAILABLE

  atlas_3_10_blas_info:
  customize UnixCCompiler
    libraries satlas not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu/atlas', '/usr/lib/x86_64-linux-gnu']
    NOT AVAILABLE

  atlas_blas_threads_info:
  Setting PTATLAS=ATLAS
  customize UnixCCompiler
    libraries ptf77blas,ptcblas,atlas not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu/atlas', '/usr/lib/x86_64-linux-gnu']
    NOT AVAILABLE

  atlas_blas_info:
  customize UnixCCompiler
  get_default_fcompiler: matching types: '['gnu95', 'intel', 'lahey', 'pg', 'absoft', 'nag', 'vast', 'compaq', 'intele', 'intelem', 'gnu', 'g95', 'pathf95', 'nagfor']'
  customize Gnu95FCompiler
  Found executable /usr/bin/gfortran
  customize Gnu95FCompiler
  customize Gnu95FCompiler using config
  compiling '_configtest.c':

  /* This file is generated from numpy/distutils/system_info.py */
  void ATL_buildinfo(void);
  int main(void) {
    ATL_buildinfo();
    return 0;
  }

  C compiler: x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.6-sXpGnM/python3.6-3.6.3=. -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC

  compile options: '-c'
  x86_64-linux-gnu-gcc: _configtest.c
  x86_64-linux-gnu-gcc -pthread _configtest.o -lf77blas -lcblas -latlas -o _configtest
  ATLAS version 3.10.3 built by buildd on Tue Sep 19 15:17:33 UTC 2017:
     UNAME    : Linux lcy01-26 4.4.0-96-generic #119-Ubuntu SMP Tue Sep 12 14:59:54 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
     INSTFLG  : -1 0 -a 1 -l 1
     ARCHDEFS : -DATL_OS_Linux -DATL_ARCH_x86SSE2 -DATL_CPUMHZ=2600 -DATL_SSE2 -DATL_SSE1 -DATL_USE64BITS -DATL_GAS_x8664
     F2CDEFS  : -DAdd_ -DF77_INTEGER=int -DStringSunStyle
     CACHEEDGE: 1048576
     F77      : /usr/bin/gfortran, version GNU Fortran (Ubuntu 7.2.0-5ubuntu1) 7.2.0
     F77FLAGS : -g -O2 -fdebug-prefix-map=/build/atlas-jedIp7/atlas-3.10.3=. -fstack-protector-strong -m64 -fPIC
     SMC      : /usr/bin/gcc, version gcc (Ubuntu 7.2.0-5ubuntu1) 7.2.0
     SMCFLAGS : -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/atlas-jedIp7/atlas-3.10.3=. -fstack-protector-strong -m64 -fPIC
     SKC      : /usr/bin/gcc, version gcc (Ubuntu 7.2.0-5ubuntu1) 7.2.0
     SKCFLAGS : -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/atlas-jedIp7/atlas-3.10.3=. -fstack-protector-strong -m64 -fPIC
  success!
  removing: _configtest.c _configtest.o _configtest
  customize UnixCCompiler
  customize UnixCCompiler
    FOUND:
      language = c
      define_macros = [('HAVE_CBLAS', None), ('ATLAS_INFO', '"\\"3.10.3\\""')]
      libraries = ['f77blas', 'cblas', 'atlas', 'f77blas', 'cblas']
      library_dirs = ['/usr/lib/x86_64-linux-gnu']

    FOUND:
      language = c
      define_macros = [('HAVE_CBLAS', None), ('ATLAS_INFO', '"\\"3.10.3\\""')]
      libraries = ['f77blas', 'cblas', 'atlas', 'f77blas', 'cblas']
      library_dirs = ['/usr/lib/x86_64-linux-gnu']

  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-req-build-j3idof1a/setup.py", line 250, in <module>
      setup_package()
    File "/tmp/pip-req-build-j3idof1a/setup.py", line 246, in setup_package
      setup(**metadata)
    File "/usr/local/lib/python3.6/dist-packages/numpy/distutils/core.py", line 135, in setup
      config = configuration()
    File "/tmp/pip-req-build-j3idof1a/setup.py", line 140, in configuration
      config.add_subpackage('sklearn')
    File "/usr/local/lib/python3.6/dist-packages/numpy/distutils/misc_util.py", line 1024, in add_subpackage
      caller_level = 2)
    File "/usr/local/lib/python3.6/dist-packages/numpy/distutils/misc_util.py", line 993, in get_subpackage
      caller_level = caller_level + 1)
    File "/usr/local/lib/python3.6/dist-packages/numpy/distutils/misc_util.py", line 930, in _get_configuration_from_setup_py
      config = setup_module.configuration(*args)
    File "sklearn/setup.py", line 83, in configuration
      maybe_cythonize_extensions(top_path, config)
    File "/tmp/pip-req-build-j3idof1a/sklearn/_build_utils/__init__.py", line 74, in maybe_cythonize_extensions
      import Cython
  ModuleNotFoundError: No module named 'Cython'

  ----------------------------------------
  Failed building wheel for scikit-learn
  Running setup.py clean for scikit-learn
Failed to build scikit-learn
Installing collected packages: scikit-learn
  Found existing installation: scikit-learn 0.19.2
    Uninstalling scikit-learn-0.19.2:
      Successfully uninstalled scikit-learn-0.19.2
  Running setup.py install for scikit-learn ... error
    Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-req-build-j3idof1a/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-i2vd3phi/install-record.txt --single-version-externally-managed --compile:
    Partial import of sklearn during the build process.
    blas_opt_info:
    blas_mkl_info:
    customize UnixCCompiler
      libraries mkl_rt not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu']
      NOT AVAILABLE

    blis_info:
    customize UnixCCompiler
      libraries blis not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu']
      NOT AVAILABLE

    openblas_info:
    customize UnixCCompiler
    customize UnixCCompiler
      libraries openblas not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu']
      NOT AVAILABLE

    atlas_3_10_blas_threads_info:
    Setting PTATLAS=ATLAS
    customize UnixCCompiler
      libraries tatlas not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu/atlas', '/usr/lib/x86_64-linux-gnu']
      NOT AVAILABLE

    atlas_3_10_blas_info:
    customize UnixCCompiler
      libraries satlas not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu/atlas', '/usr/lib/x86_64-linux-gnu']
      NOT AVAILABLE

    atlas_blas_threads_info:
    Setting PTATLAS=ATLAS
    customize UnixCCompiler
      libraries ptf77blas,ptcblas,atlas not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu/atlas', '/usr/lib/x86_64-linux-gnu']
      NOT AVAILABLE

    atlas_blas_info:
    customize UnixCCompiler
    get_default_fcompiler: matching types: '['gnu95', 'intel', 'lahey', 'pg', 'absoft', 'nag', 'vast', 'compaq', 'intele', 'intelem', 'gnu', 'g95', 'pathf95', 'nagfor']'
    customize Gnu95FCompiler
    Found executable /usr/bin/gfortran
    customize Gnu95FCompiler
    customize Gnu95FCompiler using config
    compiling '_configtest.c':

    /* This file is generated from numpy/distutils/system_info.py */
    void ATL_buildinfo(void);
    int main(void) {
      ATL_buildinfo();
      return 0;
    }

    C compiler: x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.6-sXpGnM/python3.6-3.6.3=. -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC

    compile options: '-c'
    x86_64-linux-gnu-gcc: _configtest.c
    x86_64-linux-gnu-gcc -pthread _configtest.o -lf77blas -lcblas -latlas -o _configtest
    ATLAS version 3.10.3 built by buildd on Tue Sep 19 15:17:33 UTC 2017:
       UNAME    : Linux lcy01-26 4.4.0-96-generic #119-Ubuntu SMP Tue Sep 12 14:59:54 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
       INSTFLG  : -1 0 -a 1 -l 1
       ARCHDEFS : -DATL_OS_Linux -DATL_ARCH_x86SSE2 -DATL_CPUMHZ=2600 -DATL_SSE2 -DATL_SSE1 -DATL_USE64BITS -DATL_GAS_x8664
       F2CDEFS  : -DAdd_ -DF77_INTEGER=int -DStringSunStyle
       CACHEEDGE: 1048576
       F77      : /usr/bin/gfortran, version GNU Fortran (Ubuntu 7.2.0-5ubuntu1) 7.2.0
       F77FLAGS : -g -O2 -fdebug-prefix-map=/build/atlas-jedIp7/atlas-3.10.3=. -fstack-protector-strong -m64 -fPIC
       SMC      : /usr/bin/gcc, version gcc (Ubuntu 7.2.0-5ubuntu1) 7.2.0
       SMCFLAGS : -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/atlas-jedIp7/atlas-3.10.3=. -fstack-protector-strong -m64 -fPIC
       SKC      : /usr/bin/gcc, version gcc (Ubuntu 7.2.0-5ubuntu1) 7.2.0
       SKCFLAGS : -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/atlas-jedIp7/atlas-3.10.3=. -fstack-protector-strong -m64 -fPIC
    success!
    removing: _configtest.c _configtest.o _configtest
    customize UnixCCompiler
    customize UnixCCompiler
      FOUND:
        language = c
        define_macros = [('HAVE_CBLAS', None), ('ATLAS_INFO', '"\\"3.10.3\\""')]
        libraries = ['f77blas', 'cblas', 'atlas', 'f77blas', 'cblas']
        library_dirs = ['/usr/lib/x86_64-linux-gnu']

      FOUND:
        language = c
        define_macros = [('HAVE_CBLAS', None), ('ATLAS_INFO', '"\\"3.10.3\\""')]
        libraries = ['f77blas', 'cblas', 'atlas', 'f77blas', 'cblas']
        library_dirs = ['/usr/lib/x86_64-linux-gnu']

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-req-build-j3idof1a/setup.py", line 250, in <module>
        setup_package()
      File "/tmp/pip-req-build-j3idof1a/setup.py", line 246, in setup_package
        setup(**metadata)
      File "/usr/local/lib/python3.6/dist-packages/numpy/distutils/core.py", line 135, in setup
        config = configuration()
      File "/tmp/pip-req-build-j3idof1a/setup.py", line 140, in configuration
        config.add_subpackage('sklearn')
      File "/usr/local/lib/python3.6/dist-packages/numpy/distutils/misc_util.py", line 1024, in add_subpackage
        caller_level = 2)
      File "/usr/local/lib/python3.6/dist-packages/numpy/distutils/misc_util.py", line 993, in get_subpackage
        caller_level = caller_level + 1)
      File "/usr/local/lib/python3.6/dist-packages/numpy/distutils/misc_util.py", line 930, in _get_configuration_from_setup_py
        config = setup_module.configuration(*args)
      File "sklearn/setup.py", line 83, in configuration
        maybe_cythonize_extensions(top_path, config)
      File "/tmp/pip-req-build-j3idof1a/sklearn/_build_utils/__init__.py", line 74, in maybe_cythonize_extensions
        import Cython
    ModuleNotFoundError: No module named 'Cython'

    ----------------------------------------
  Rolling back uninstall of scikit-learn
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-req-build-j3idof1a/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-i2vd3phi/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-req-build-j3idof1a/

我也尝试了更传统的命令

!pip install git+https://github.com/scikit-learn/scikit-learn.git

这基本上给我相同的结果。

Collecting git+https://github.com/scikit-learn/scikit-learn.git
  Cloning https://github.com/scikit-learn/scikit-learn.git to /tmp/pip-req-build-35q123ah
Requirement already satisfied: numpy>=1.8.2 in /usr/local/lib/python3.6/dist-packages (from scikit-learn==0.20.dev0) (1.14.5)
Requirement already satisfied: scipy>=0.13.3 in /usr/local/lib/python3.6/dist-packages (from scikit-learn==0.20.dev0) (0.19.1)
Building wheels for collected packages: scikit-learn
  Running setup.py bdist_wheel for scikit-learn ... error
  Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-req-build-35q123ah/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-mmpe1xku --python-tag cp36:
  Partial import of sklearn during the build process.
  blas_opt_info:
  blas_mkl_info:
  customize UnixCCompiler
    libraries mkl_rt not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu']
    NOT AVAILABLE

  blis_info:
  customize UnixCCompiler
    libraries blis not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu']
    NOT AVAILABLE

  openblas_info:
  customize UnixCCompiler
  customize UnixCCompiler
    libraries openblas not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu']
    NOT AVAILABLE

  atlas_3_10_blas_threads_info:
  Setting PTATLAS=ATLAS
  customize UnixCCompiler
    libraries tatlas not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu/atlas', '/usr/lib/x86_64-linux-gnu']
    NOT AVAILABLE

  atlas_3_10_blas_info:
  customize UnixCCompiler
    libraries satlas not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu/atlas', '/usr/lib/x86_64-linux-gnu']
    NOT AVAILABLE

  atlas_blas_threads_info:
  Setting PTATLAS=ATLAS
  customize UnixCCompiler
    libraries ptf77blas,ptcblas,atlas not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu/atlas', '/usr/lib/x86_64-linux-gnu']
    NOT AVAILABLE

  atlas_blas_info:
  customize UnixCCompiler
  get_default_fcompiler: matching types: '['gnu95', 'intel', 'lahey', 'pg', 'absoft', 'nag', 'vast', 'compaq', 'intele', 'intelem', 'gnu', 'g95', 'pathf95', 'nagfor']'
  customize Gnu95FCompiler
  Found executable /usr/bin/gfortran
  customize Gnu95FCompiler
  customize Gnu95FCompiler using config
  compiling '_configtest.c':

  /* This file is generated from numpy/distutils/system_info.py */
  void ATL_buildinfo(void);
  int main(void) {
    ATL_buildinfo();
    return 0;
  }

  C compiler: x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.6-sXpGnM/python3.6-3.6.3=. -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC

  compile options: '-c'
  x86_64-linux-gnu-gcc: _configtest.c
  x86_64-linux-gnu-gcc -pthread _configtest.o -lf77blas -lcblas -latlas -o _configtest
  ATLAS version 3.10.3 built by buildd on Tue Sep 19 15:17:33 UTC 2017:
     UNAME    : Linux lcy01-26 4.4.0-96-generic #119-Ubuntu SMP Tue Sep 12 14:59:54 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
     INSTFLG  : -1 0 -a 1 -l 1
     ARCHDEFS : -DATL_OS_Linux -DATL_ARCH_x86SSE2 -DATL_CPUMHZ=2600 -DATL_SSE2 -DATL_SSE1 -DATL_USE64BITS -DATL_GAS_x8664
     F2CDEFS  : -DAdd_ -DF77_INTEGER=int -DStringSunStyle
     CACHEEDGE: 1048576
     F77      : /usr/bin/gfortran, version GNU Fortran (Ubuntu 7.2.0-5ubuntu1) 7.2.0
     F77FLAGS : -g -O2 -fdebug-prefix-map=/build/atlas-jedIp7/atlas-3.10.3=. -fstack-protector-strong -m64 -fPIC
     SMC      : /usr/bin/gcc, version gcc (Ubuntu 7.2.0-5ubuntu1) 7.2.0
     SMCFLAGS : -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/atlas-jedIp7/atlas-3.10.3=. -fstack-protector-strong -m64 -fPIC
     SKC      : /usr/bin/gcc, version gcc (Ubuntu 7.2.0-5ubuntu1) 7.2.0
     SKCFLAGS : -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/atlas-jedIp7/atlas-3.10.3=. -fstack-protector-strong -m64 -fPIC
  success!
  removing: _configtest.c _configtest.o _configtest
  customize UnixCCompiler
  customize UnixCCompiler
    FOUND:
      language = c
      define_macros = [('HAVE_CBLAS', None), ('ATLAS_INFO', '"\\"3.10.3\\""')]
      libraries = ['f77blas', 'cblas', 'atlas', 'f77blas', 'cblas']
      library_dirs = ['/usr/lib/x86_64-linux-gnu']

    FOUND:
      language = c
      define_macros = [('HAVE_CBLAS', None), ('ATLAS_INFO', '"\\"3.10.3\\""')]
      libraries = ['f77blas', 'cblas', 'atlas', 'f77blas', 'cblas']
      library_dirs = ['/usr/lib/x86_64-linux-gnu']

  Traceback (most recent call last):
    File "<string>", line 1, in <module>
    File "/tmp/pip-req-build-35q123ah/setup.py", line 250, in <module>
      setup_package()
    File "/tmp/pip-req-build-35q123ah/setup.py", line 246, in setup_package
      setup(**metadata)
    File "/usr/local/lib/python3.6/dist-packages/numpy/distutils/core.py", line 135, in setup
      config = configuration()
    File "/tmp/pip-req-build-35q123ah/setup.py", line 140, in configuration
      config.add_subpackage('sklearn')
    File "/usr/local/lib/python3.6/dist-packages/numpy/distutils/misc_util.py", line 1024, in add_subpackage
      caller_level = 2)
    File "/usr/local/lib/python3.6/dist-packages/numpy/distutils/misc_util.py", line 993, in get_subpackage
      caller_level = caller_level + 1)
    File "/usr/local/lib/python3.6/dist-packages/numpy/distutils/misc_util.py", line 930, in _get_configuration_from_setup_py
      config = setup_module.configuration(*args)
    File "sklearn/setup.py", line 83, in configuration
      maybe_cythonize_extensions(top_path, config)
    File "/tmp/pip-req-build-35q123ah/sklearn/_build_utils/__init__.py", line 74, in maybe_cythonize_extensions
      import Cython
  ModuleNotFoundError: No module named 'Cython'

  ----------------------------------------
  Failed building wheel for scikit-learn
  Running setup.py clean for scikit-learn
Failed to build scikit-learn
Installing collected packages: scikit-learn
  Found existing installation: scikit-learn 0.19.2
    Uninstalling scikit-learn-0.19.2:
      Successfully uninstalled scikit-learn-0.19.2
  Running setup.py install for scikit-learn ... error
    Complete output from command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-req-build-35q123ah/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-d1gnws67/install-record.txt --single-version-externally-managed --compile:
    Partial import of sklearn during the build process.
    blas_opt_info:
    blas_mkl_info:
    customize UnixCCompiler
      libraries mkl_rt not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu']
      NOT AVAILABLE

    blis_info:
    customize UnixCCompiler
      libraries blis not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu']
      NOT AVAILABLE

    openblas_info:
    customize UnixCCompiler
    customize UnixCCompiler
      libraries openblas not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu']
      NOT AVAILABLE

    atlas_3_10_blas_threads_info:
    Setting PTATLAS=ATLAS
    customize UnixCCompiler
      libraries tatlas not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu/atlas', '/usr/lib/x86_64-linux-gnu']
      NOT AVAILABLE

    atlas_3_10_blas_info:
    customize UnixCCompiler
      libraries satlas not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu/atlas', '/usr/lib/x86_64-linux-gnu']
      NOT AVAILABLE

    atlas_blas_threads_info:
    Setting PTATLAS=ATLAS
    customize UnixCCompiler
      libraries ptf77blas,ptcblas,atlas not found in ['/usr/local/lib', '/usr/lib', '/usr/lib/x86_64-linux-gnu/atlas', '/usr/lib/x86_64-linux-gnu']
      NOT AVAILABLE

    atlas_blas_info:
    customize UnixCCompiler
    get_default_fcompiler: matching types: '['gnu95', 'intel', 'lahey', 'pg', 'absoft', 'nag', 'vast', 'compaq', 'intele', 'intelem', 'gnu', 'g95', 'pathf95', 'nagfor']'
    customize Gnu95FCompiler
    Found executable /usr/bin/gfortran
    customize Gnu95FCompiler
    customize Gnu95FCompiler using config
    compiling '_configtest.c':

    /* This file is generated from numpy/distutils/system_info.py */
    void ATL_buildinfo(void);
    int main(void) {
      ATL_buildinfo();
      return 0;
    }

    C compiler: x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -g -fdebug-prefix-map=/build/python3.6-sXpGnM/python3.6-3.6.3=. -specs=/usr/share/dpkg/no-pie-compile.specs -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC

    compile options: '-c'
    x86_64-linux-gnu-gcc: _configtest.c
    x86_64-linux-gnu-gcc -pthread _configtest.o -lf77blas -lcblas -latlas -o _configtest
    ATLAS version 3.10.3 built by buildd on Tue Sep 19 15:17:33 UTC 2017:
       UNAME    : Linux lcy01-26 4.4.0-96-generic #119-Ubuntu SMP Tue Sep 12 14:59:54 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
       INSTFLG  : -1 0 -a 1 -l 1
       ARCHDEFS : -DATL_OS_Linux -DATL_ARCH_x86SSE2 -DATL_CPUMHZ=2600 -DATL_SSE2 -DATL_SSE1 -DATL_USE64BITS -DATL_GAS_x8664
       F2CDEFS  : -DAdd_ -DF77_INTEGER=int -DStringSunStyle
       CACHEEDGE: 1048576
       F77      : /usr/bin/gfortran, version GNU Fortran (Ubuntu 7.2.0-5ubuntu1) 7.2.0
       F77FLAGS : -g -O2 -fdebug-prefix-map=/build/atlas-jedIp7/atlas-3.10.3=. -fstack-protector-strong -m64 -fPIC
       SMC      : /usr/bin/gcc, version gcc (Ubuntu 7.2.0-5ubuntu1) 7.2.0
       SMCFLAGS : -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/atlas-jedIp7/atlas-3.10.3=. -fstack-protector-strong -m64 -fPIC
       SKC      : /usr/bin/gcc, version gcc (Ubuntu 7.2.0-5ubuntu1) 7.2.0
       SKCFLAGS : -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/atlas-jedIp7/atlas-3.10.3=. -fstack-protector-strong -m64 -fPIC
    success!
    removing: _configtest.c _configtest.o _configtest
    customize UnixCCompiler
    customize UnixCCompiler
      FOUND:
        language = c
        define_macros = [('HAVE_CBLAS', None), ('ATLAS_INFO', '"\\"3.10.3\\""')]
        libraries = ['f77blas', 'cblas', 'atlas', 'f77blas', 'cblas']
        library_dirs = ['/usr/lib/x86_64-linux-gnu']

      FOUND:
        language = c
        define_macros = [('HAVE_CBLAS', None), ('ATLAS_INFO', '"\\"3.10.3\\""')]
        libraries = ['f77blas', 'cblas', 'atlas', 'f77blas', 'cblas']
        library_dirs = ['/usr/lib/x86_64-linux-gnu']

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-req-build-35q123ah/setup.py", line 250, in <module>
        setup_package()
      File "/tmp/pip-req-build-35q123ah/setup.py", line 246, in setup_package
        setup(**metadata)
      File "/usr/local/lib/python3.6/dist-packages/numpy/distutils/core.py", line 135, in setup
        config = configuration()
      File "/tmp/pip-req-build-35q123ah/setup.py", line 140, in configuration
        config.add_subpackage('sklearn')
      File "/usr/local/lib/python3.6/dist-packages/numpy/distutils/misc_util.py", line 1024, in add_subpackage
        caller_level = 2)
      File "/usr/local/lib/python3.6/dist-packages/numpy/distutils/misc_util.py", line 993, in get_subpackage
        caller_level = caller_level + 1)
      File "/usr/local/lib/python3.6/dist-packages/numpy/distutils/misc_util.py", line 930, in _get_configuration_from_setup_py
        config = setup_module.configuration(*args)
      File "sklearn/setup.py", line 83, in configuration
        maybe_cythonize_extensions(top_path, config)
      File "/tmp/pip-req-build-35q123ah/sklearn/_build_utils/__init__.py", line 74, in maybe_cythonize_extensions
        import Cython
    ModuleNotFoundError: No module named 'Cython'

    ----------------------------------------
  Rolling back uninstall of scikit-learn
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-req-build-35q123ah/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-d1gnws67/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-req-build-35q123ah/

根据我的查询,似乎安装失败的最大问题是未安装依赖项。然而,Google Colab 似乎已经安装了所有依赖项。事实上,sk-learn 已经安装好了。

当我运行这行代码时

!pip install -U scikit-learn

输出结果为:

已经具备最新版本的要求:scikit-learn /usr/local/lib/python3.6/dist-packages (0.19.2)

1个回答

1
问题在于我需要安装Cython。我不确定为什么需要这样做,因为似乎已经安装了Cython,但是添加这行代码就解决了问题。
!pip install Cython

如果你遵循这个建议,不要忘记先卸载sk-learn,然后重新加载你正在使用的任何模块。
例如:
!pip uninstall sklearn -y
!pip install Cython
!pip install https://github.com/Santosh-Gupta/scikit-learn/archive/master.zip

import importlib
import sklearn.manifold
importlib.reload(sklearn.manifold)
from sklearn.manifold import TSNE

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接