我正在尝试在作为 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