2

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

Gary Liu
  • 13,758
  • 1
  • 17
  • 32
pjh
  • 43
  • 1
  • 4

2 Answers2

1

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.

Peter Pan
  • 23,476
  • 4
  • 25
  • 43
  • Ok thanks a lot for the explanations Peter. I'm trying that now and will let you know how it goes. – pjh Jun 01 '17 at 12:54
  • Ok, thanks a lot @PeterSmith, it works! In fact I used a slightly different way: from the package location I ran a "python setup.py bdist" and obtained a .pyd file. I zipped this file and used it as the script bundle, and the Python module in Azure ML worked successfully. You saved me a lot of time!! Thanks again... – pjh Jun 01 '17 at 19:17
0

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
stevedem
  • 11
  • 2
  • Thanks for the reply stevedem, I did try and although it works with some other packages, for this one it doesn't - I believe it's something to do with the extension of the file, the pyxdameraulevenshtein module has a .pyx extension with a corresponding .c file, whereas typical modules have a .py extension. I'm not sure if .pyx extension can be imported in Azure ML ? – pjh Jun 01 '17 at 08:29