繁体   English   中英

在数据块上安装新版本后,pandas 版本未更新

[英]pandas version is not updated after installing a new version on databricks

当我在数据块上运行 python3.7 代码时,我试图解决熊猫的问题。

错误是:

 ImportError: cannot import name 'roperator' from 'pandas.core.ops' (/databricks/python/lib/python3.7/site-packages/pandas/core/ops.py)

熊猫版本:

pd.__version__
0.24.2

我跑

 from pandas.core.ops import roperator

在我的笔记本电脑上

pandas 0.25.1

所以,我尝试在数据块上升级熊猫。

%sh pip uninstall -y pandas
Successfully uninstalled pandas-1.1.2

%sh pip install pandas==0.25.1
 Collecting pandas==0.25.1
 Downloading pandas-0.25.1-cp37-cp37m-manylinux1_x86_64.whl (10.4 MB)
 Requirement already satisfied: python-dateutil>=2.6.1 in /databricks/conda/envs/databricks-ml/lib/python3.7/site-packages (from pandas==0.25.1) (2.8.0)
 Requirement already satisfied: numpy>=1.13.3 in /databricks/conda/envs/databricks-ml/lib/python3.7/site-packages (from pandas==0.25.1) (1.16.2)
 Requirement already satisfied: pytz>=2017.2 in /databricks/conda/envs/databricks-ml/lib/python3.7/site-packages (from pandas==0.25.1) (2018.9)
 Requirement already satisfied: six>=1.5 in /databricks/conda/envs/databricks-ml/lib/python3.7/site-packages (from python-dateutil>=2.6.1->pandas==0.25.1) (1.12.0)
 Installing collected packages: pandas
 ERROR: After October 2020 you may experience errors when installing or updating packages. 
  This is because pip will change the way that it resolves dependency conflicts.

  We recommend you use --use-feature=2020-resolver to test your packages with the new resolver before it becomes the default.

  mlflow 1.8.0 requires alembic, which is not installed.
  mlflow 1.8.0 requires prometheus-flask-exporter, which is not installed.
  mlflow 1.8.0 requires sqlalchemy<=1.3.13, which is not installed.
  sklearn-pandas 2.0.1 requires numpy>=1.18.1, but you'll have numpy 1.16.2 which is incompatible.
   sklearn-pandas 2.0.1 requires pandas>=1.0.5, but you'll have pandas 0.25.1 which is incompatible.
   sklearn-pandas 2.0.1 requires scikit-learn>=0.23.0, but you'll have scikit-learn 0.20.3 which is incompatible.
   sklearn-pandas 2.0.1 requires scipy>=1.4.1, but you'll have scipy 1.2.1 which is incompatible.
   Successfully installed pandas-0.25.1

当我运行时:

 import pandas as pd
  pd.__version__

它还是:

 0.24.2

我错过了什么吗?

谢谢

真的建议通过集群初始化脚本安装库。 %sh命令仅在驱动程序节点上执行,而不在执行程序节点上执行。 并且它也不会影响已经运行的 Python 实例。

正确的解决方案是使用dbutils.library commands ,如下所示:

dbutils.library.installPyPI("pandas", "1.0.1")
dbutils.library.restartPython()

这会将库安装到所有位置,但需要重新启动 Python 以获取新库。

在此处输入图片说明

此外,虽然可以只指定包名,但建议明确指定版本,因为某些库版本可能与运行时不兼容。 此外,请考虑使用已更新库版本的较新运行时 - 检查运行时发行说明以找出开箱即用的库版本。

对于较新的 Databricks 运行时,您可以使用新的魔法命令: %pip%conda来安装依赖项。 有关更多详细信息,请参阅文档

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM