让 colab 使用最新安装的库

Make colab use the latest installation of a library

我正在尝试使用 sklearn 的前沿版本,从他们的 github 安装它,如下图第 2 行所示。第 5 行从这个版本的 sklearn 导入了一些函数。此行适用于我的本地,不适用于 Google Colab。我是否缺少提示工具使用最新安装版本而不是其缓存版本的内容?

我不确定为什么会这样,但如果你在安装最新的开发者之前卸载 scikit-learn,它会起作用:

[1] !pip uninstall scikit-learn -y
Uninstalling scikit-learn-0.19.1:
  Successfully uninstalled scikit-learn-0.19.1

[2]!pip install Cython
   !pip install git+git://github.com/scikit-learn/scikit-learn.git
Requirement already satisfied: Cython in /usr/local/lib/python3.6/dist-packages (0.28.2)
Collecting git+git://github.com/scikit-learn/scikit-learn.git
  Cloning git://github.com/scikit-learn/scikit-learn.git to /tmp/pip-req-build-d59ukisw
Requirement already satisfied: numpy>=1.8.2 in /usr/local/lib/python3.6/dist-packages (from scikit-learn==0.20.dev0) (1.14.3)
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 ... done
  Stored in directory: /tmp/pip-ephem-wheel-cache-is88dk15/wheels/a1/50/0e/316ef2ff8d4cfade292bd20b49efda94727688a153382745a6
Successfully built scikit-learn
Installing collected packages: scikit-learn
Successfully installed scikit-learn-0.20.dev0

[3] !pip freeze | grep scikit
scikit-image==0.13.1
scikit-learn==0.20.dev0

[4] from sklearn.preprocessing import CategoricalEncoder

[5] import sklearn
    sklearn.__version__
'0.20.dev0'