0

I would like to install the Python fastText wrapper of the Facebook C++ library on Azure ML Studio. This library is installed and works properly on my laptop.

I tried to follow the instructions in this Stack Overflow thread for the upload on Azure without success.

The code in my "Execute Python Script" is minimal: I am just unzipping and loading the fastText package that I installed locally on my machine and then calling a help function on the "train_supervised" attribute of the fastText module to verify that the package is imported correctly


# The script MUST contain a function named azureml_main
# which is the entry point for this module.

import fastText

# The entry point function can contain up to two input arguments:
#   Param<dataframe1>: a pandas.DataFrame
#   Param<dataframe2>: a pandas.DataFrame

def azureml_main(dataframe1 = None, dataframe2 = None):

    print(help(fastText.train_supervised))

    # Return value must be of a sequence of pandas.DataFrame
    return dataframe1,

Upon running this minimal Azure experiment I get the following error:

Traceback (most recent call last): File "C:\server\invokepy.py", line 199, in batch odfs = mod.azureml_main(*idfs) File "C:\temp\e6acccec62994066a25e0d758090e749.py", line 44, in azureml_main print(help(fastText.train_supervised))AttributeError: module 'fastText' has no attribute 'train_supervised'Process returned with non-zero exit code 1---------- End of error message from Python interpreter ---------- Process exited with error code -2

I have also tried to create a virtual environment on my local machine (using conda) and to install fastText and its dependencies in it, but I did not manage. The goal would have been then to zip and upload those libraries to Azure. This is because, for compatibility with the Azure Python environment, I need the 3.5.1 Python version (Anaconda 4.0).

Any help/guidance appreciated!

Marco
  • 91
  • 8

1 Answers1

0

There is a more completed answer for the SO thread post by me: Updating pandas to version 0.19 in Azure ML Studio.

And you should install Cypython and fasttext via pip in a virtualenv, then you need to package these modules below (list by pip freeze) to a zip file and upload it to Azure ML Studio.

Cython==0.29.10
fasttext==0.8.3
future==0.17.1
numpy==1.16.4

However, there are two issue in your code as below.

  1. To import fasttext in Python, not fastText which will cause ModuleNotFoundError: No module named 'fastText'.

  2. Actually, there is not an attribute named train_supervised, I got the error AttributeError: module 'fasttext' has no attribute 'train_supervised'. And I tried to find it via the online fastText API Reference All Functions & All Variables, it doesn't exist really, just supervised.

    enter image description here

Hope it helps.

Peter Pan
  • 23,476
  • 4
  • 25
  • 43
  • Thank you for the reply! Actually the package I was referring to is [**fastText**](https://github.com/facebookresearch/fastText/tree/master/python), and not [**fasttext**](https://pypi.org/project/fasttext/). I wanted to use the first one as it seems the officially supported Python binding and because it is possible to use it together with [**skift**](https://pypi.org/project/skift/0.0.12/) (which gives compatibility with scikit-learn functionalities). Does your installation protocol work only for PyPi packages like **fasttext** or does it also work for git-cloned packages like **fastText**? – Marco Jun 15 '19 at 11:12
  • @Marco My installation protocol works for PyPi packages. I didn't try to use git-cloned packages. – Peter Pan Jun 17 '19 at 01:29
  • Thank you for the suggestion! Unfortunately even by following your protocol **step by step** I didn't manage to install **fasttext** on Azure. Locally on my machine everything works. But when I run the experiment on Azure ML with the Execute Python Script containing the line "import fasttext" I get: ".\Script Bundle\fasttext\__init__.py", line 1, in from .fasttext import skipgramImportError: No module named 'fasttext.fasttext'Process returned with non-zero exit code 1". One last question: could you please try it on your personal Azure workspace to see if you get the same error? Thanks – Marco Jun 17 '19 at 13:40