如何在 azure ML 中导入某些 python 库?就像 import humanfriendly 行给出错误

How can certain python libraries be imported in azure ML?Like the line import humanfriendly gives error

在执行python模块。行

import humanfriendly

报错。 如何解决这个问题?

你的描述不清楚,我不知道你说的import humanfriendly报错是怎么回事。所以我只能为你做 post 我关于如何在 Azure ML 中安装 humanfriendly Python 包的步骤,如下所示。

  1. 根据Technical Notes of the document "Execute Python Script", I download the humanfriendly package from here. I decompressed the package (the same for either .whl file or .tar.gz文件部分),将其humanfriendly目录打包为zip文件

  2. 然后我点击按钮+New和select DATASET选项卡从本地文件上传一个新的数据集,如下图。

    图1.点击按钮+New 图 2. Select 选项卡 DATASET 图 3. 从本地文件上传新数据集

  3. 拖放数据集模块humanfriendly.zip和一个Execute Python Script模块来连接它们并编写Python代码,如下所示。

这是我在 Execute Python Script 中的测试代码。

import humanfriendly

def azureml_main(dataframe1 = None, dataframe2 = None):
    user_input = '16G'
    num_bytes = humanfriendly.parse_size(user_input)
    print num_bytes

终于,我运行实验成功了


更新:我的 humanfriendly zip 的文件结构树。我解压了wheel文件,直接打包到humanfriendly目录下。

humanfriendly
├── data.csv
└── humanfriendly
    ├── cli.py
    ├── compat.py
    ├── __init__.py
    ├── prompts.py
    ├── sphinx.py
    ├── tables.py
    ├── terminal.py
    ├── tests.py
    ├── text.py
    └── usage.py