gpt4 book ai didi

python - 在数据 block 上安装新版本后,pandas 版本未更新

转载 作者:行者123 更新时间:2023-12-03 19:05:03 26 4
gpt4 key购买 nike

当我在数据块上运行 python3.7 代码时,我试图解决 Pandas 的问题。
错误是:

 ImportError: cannot import name 'roperator' from 'pandas.core.ops' (/databricks/python/lib/python3.7/site-packages/pandas/core/ops.py)
Pandas 版本:
pd.__version__
0.24.2
我跑
 from pandas.core.ops import roperator
在我的笔记本电脑上
pandas 0.25.1
所以,我尝试在数据块上升级 Pandas 。
%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
我错过了什么吗?
谢谢

最佳答案

真的建议通过 cluster initialization script 安装库. %sh命令仅在驱动程序节点上执行,而不在执行程序节点上执行。并且它也不会影响已经运行的 Python 实例。
正确的解决方案是使用 dbutils.library commands , 像这样:

dbutils.library.installPyPI("pandas", "1.0.1")
dbutils.library.restartPython()
这会将库安装到所有位置,但需要重新启动 Python 以获取新库。
enter image description here
此外,虽然可以只指定包名,但建议明确指定版本,因为某些库版本可能与运行时不兼容。此外,请考虑使用已更新库版本的较新运行时 - 检查 release notes for runtimes找出开箱即用的库版本。
对于较新的 Databricks 运行时,您可以使用新的魔术命令: %pip%conda安装依赖项。见 documentation更多细节。

关于python - 在数据 block 上安装新版本后,pandas 版本未更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63821633/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com