pjh
pjh

Reputation: 43

Azure ML Python with Script Bundle cannot import module

In Azure ML, I'm trying to execute a Python module that needs to import the module pyxdameraulevenshtein (https://pypi.python.org/pypi/pyxDamerauLevenshtein).

I followed the usual way, which is to create a zip file and then import it; however for this specific module, it seems to never be able to find it. The error message is as usual:

ImportError: No module named 'pyxdameraulevenshtein'

Has anyone included this pyxdameraulevenshtein module in Azure ML with success ?

(I took the package from https://pypi.python.org/pypi/pyxDamerauLevenshtein.)

Thanks for any help you can provide,

PH

Upvotes: 2

Views: 3346

Answers (2)

Peter Pan
Peter Pan

Reputation: 24128

I viewed the pyxdameraulevenshtein module page, there are two packages you can download which include a wheel file for MacOS and a source code tar file. I don't think you can directly use the both on Azure ML, because the MacOS one is just a share library .so file for darwin which is not compatible with Azure ML, and the other you need to first compile it.

So my suggestion is as below for using pyxdameraulevenshtein.

  1. First, compile the source code of pyxdameraulevenshtein to a DLL file on Windows, please refer to the document for Python 2/3 or search for doing this.
  2. Write a Python script using the DLL you compiled to implement your needs, please refer to the SO thread How can I use a DLL file from Python? for how to use DLL from Python and refer to the Azure offical tutorial to write your Python script
  3. Package your Python script and DLL file as a zip file, then to upload the zip file to use it in Execute Python script model of Azure ML.

Hope it helps.

Upvotes: 1

stevedem
stevedem

Reputation: 11

Adding the path to pyxdameraulevenshtein to your system path should alleviate this issue. The script checks the system path that the python script is running on and doesn't know where else to look for anything other than the default packages. If your python script is in the same directory as the pyxdameraulevenshtein package in your ZIP file, this should do the trick. Because you are running this within Azure ML and can't be sure of the exact location of your script each time you run it, this solution should account for that.

import os
import sys

sys.path.append(os.path.join(os.getcwd(), 'pyxdameraulevenshtein'))

import pyxdameraulevenshtein

Upvotes: 0

Related Questions