title: Python UDF for piglatin script not finding re module
body: <p>I'm having trouble creating a UDF for a piglatin script I'm using. My problem is that when I run the script with <code>pig script.pig</code> I get the following error:</p>
  
  <pre><code>[main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1121: Python Error. Traceback (most recent call last):
    File "utils.py", line 3, in &lt;module&gt;
      import re
  ImportError: No module named re
  </code></pre>
  
  <p>And on my "utils.py" script, I'm importing the module like so: <code>import re</code></p>
  
  <p>Why is it not finding the <code>re</code> module and how can I fix it?</p>
  
  <p><strong>Edit</strong>
  I should note that if I run the python script directly using the <code>python</code> command, I don't get an error saying that it couldn't find the  <code>re</code> module.</p>
  
  <p><strong>Edit 2</strong></p>
  
  <p>Ok, based on the comments, I installed jython (which wasn't installed on my system) and here are the outputs of <code>print sys.path</code> for my script:</p>
  
  <p><em>Using python</em></p>
  
  <pre><code>['/home/hduser/bqmScripts/betsScripts', '/usr/lib/python2.6', '/usr/lib/python2.6/plat-linux2', '/usr/lib/python2.6/lib-tk', '/usr/lib/python2.6/lib-old', '/usr/lib/python2.6/lib-dynload', '/usr/lib/python2.6/dist-packages', '/usr/lib/python2.6/dist-packages/PIL', '/usr/lib/python2.6/dist-packages/gst-0.10', '/usr/lib/pymodules/python2.6', '/usr/lib/python2.6/dist-packages/gtk-2.0', '/usr/lib/pymodules/python2.6/gtk-2.0', '/usr/local/lib/python2.6/dist-packages']
  </code></pre>
  
  <p><em>Using Jython</em></p>
  
  <pre><code>['', '/usr/share/jython/Lib', '/usr/lib/site-python', '__classpath__']
  </code></pre>
  
  <p><em>Using pig</em></p>
  
  <pre><code>['/pig/lib/Lib', '__classpath__', '__pyclasspath__/']
  </code></pre>
  
  <p>After seeing this, I tried to add the missing path elements from jython into the pig version, and what I get now is this:</p>
  
  <pre><code> File "utils.py", line 8, in &lt;module&gt;
      import re
    File "/usr/share/jython/Lib/re.py", line 7, in &lt;module&gt;
      import sre, sys
    File "/usr/share/jython/Lib/sre.py", line 97, in &lt;module&gt;
      import sre_compile
    File "/usr/share/jython/Lib/sre_compile.py", line 17, in &lt;module&gt;
      assert _sre.MAGIC == MAGIC, "SRE module mismatch"
  AssertionError: SRE module mismatch
  </code></pre>
  
  <p><strong>SOLVED</strong></p>
  
  <p>To solve my latest error message I looked for the version of jython that my pig installation was using (2.5) and installed that one manually. That fixed the issue.</p>