首页 > 解决方案 > pip install 后无法在 Google AI Platform Notebook 中导入 sklearn_pandas

问题描述

我正在使用 Google 的 AI Platform Notebook(目前仍处于测试阶段)。我上传了一个依赖于 sklearn_pandas 的 python 脚本,我收到了这个错误:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-4-24f79569b871> in <module>
----> 1 from sklearn_pandas import DataFrameMapper

ImportError: No module named 'sklearn_pandas'

然后我尝试 pip 安装它:

!pip install sklearn-pandas

我重新启动了内核,但它仍然得到相同的 ImportError。我这样做是为了确认确实安装了 sklearn pandas:

!pip list |grep -i sklearn

DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
sklearn-pandas (1.8.0)

有人试过这个吗?在此之前我使用过google colab,我从来没有遇到过这样的困难。如果 Google colab 级别的用户体验可以移植到这个 beta 产品中,那就太好了。我认为这可能是一个一般的 python 模块导入问题,而不仅仅是 sklearn_pandas。

标签: google-cloud-platformjupyter-notebooksklearn-pandasgcp-ai-platform-notebook

解决方案


我想可能是

%pip install sklearn-pandas

而不是“!pip”。


推荐阅读