python - 在 Azure Batch 上运行 python 脚本
问题描述
我正在尝试在作为 linux dsvm 的 azure batch 上执行 python 脚本,以便该脚本可以安装 python 包,然后执行 python 脚本。
以下是我使用的代码:
try:
from pip import main as pipmain
except ImportError:
from pip._internal import main as pipmain
try:
import pandas as pd
except:
pipmain(['install', 'pandas',"])
import pandas
当我在 azure Batch 命令行上运行 python 脚本时,池任务在最后一条语句(导入 pandas)处出错,尽管我可以在标准输出日志文件中看到安装了 pandas、numpy 等包。
似乎这些软件包安装在其他位置,并且在尝试导入时尝试从其他位置导入。它给出了错误 ImportError: No module named pandas in the stderr.txt file on the azure batch pool tasks。
我试图安装 python 包并将其导入相同脚本的原因是因为天蓝色批处理命令行不允许我编写 2 个命令,例如
pip install pandas
python test.py
它首先安装软件包,然后调用它只是导入熊猫库的脚本。
我还在批处理池的启动任务中使用了该pip install pandas
命令pip install --install-option="--prefix=$AZ_BATCH_TASK_WORKING_DIR" pandas
。AZ_BATCH_TASK_WORKING_DIR 据我了解是任务批处理运行时任务和脚本可以访问的工作目录
有没有办法在 Azure Batch 上成功运行 python 脚本。在moemt iam 只运行一个命令:import pandas
解决方案
推荐阅读
- visual-studio-code - VS Code + PHP Intelephense + Remote-SSH + Symfony 3:未定义的方法错误
- php - KNP Paginator 在 Symfony 5 中显示 Invalid item per page number 错误
- elasticsearch - 获取 Elasticsearch 中字段值与任何数组元素匹配的所有文档
- python - Pandas 按日期分组和计数。然后将计数转置为列名
- python - 如何将列表的一系列元素添加到python中的另一个列表
- c# - 更新选定值后如何更新数据网格
- python - Python glob 没有找到任何结果
- mysql - 我可以使用带有 MySQL 事务的文件来更新 mariadb 吗?
- ios - 更新 xcode 后反应原生 8badf00d
- python - 来自一些 csv 文件的 Python 字典