pythonazureazure-machine-learning-serviceml-studio

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


In execute python module. The line

import humanfriendly

gives error. How to fix this?


Solution

  • Your description is not clear, I don't know what happended when you got error via import humanfriendly as you said. So I just can do for you that only post my steps about how to install humanfriendly Python package in Azure ML, as below.

    1. According to the section 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 file), and package its humanfriendly directory as a zip file.

    2. Then I click the botton +New and select the DATASET tab to Upload a new dataset from a local file, as the figures below.

      Fig 1. Click the botton +New enter image description here Fig 2. Select the tab DATASET enter image description here Fig 3. Upload a new dataset from a local file enter image description here

    3. Drag & drop the dataset module humanfriendly.zip and a Execute Python Script module to connect them and write the Python code, as below.

    enter image description here

    Here is My testing code in the 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
    

    Finally, I ran the experiment successfully.


    Update: The file structure tree of my humanfriendly zip. I decompressed the wheel file and just package the humanfriendly directory.

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