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

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了未能直接从Github在Google Colab中安装Sk-learn(scikit-learn)相关的知识,希望对你有一定的参考价值。

我正在使用Google Colaboratory,它似乎已经以某种方式内置了sk-learn,因为你需要做的就是导入TSNE模块就是from sklearn.manifold import TSNE

我已经从我试图安装的github中分出了一个版本的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('
', '
');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('
', '
');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('
', '
');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('
', '
');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('
', '
');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('
', '
');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/

从我的查看,似乎未能安装的最大问题是没有安装依赖项。但是,谷歌Colab似乎安装了所有这些。事实上,似乎已经安装了sk-learn。

当我运行这一行

!pip install -U scikit-learn

输出是

要求已经是最新的:scikit-learn in /usr/local/lib/python3.6/dist-packages(0.19.2)

答案

问题是我需要安装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

以上是关于未能直接从Github在Google Colab中安装Sk-learn(scikit-learn)的主要内容,如果未能解决你的问题,请参考以下文章

如何直接将文件从 colab 复制到 github repo? (可以将 notebook 保存在 Github repo 中)

关于 Google Colab Transformer 教程的问题

将 Google Colab ipynb 推送到 Github?

如何在 Google Colab 中编辑和保存文本文件 (.py)?

在Google Colab中导入一个本地模块或.py文件

如何在 Google Colab 上安装 nvidia apex