You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pig.apache.org by Chris Diehl <cp...@gmail.com> on 2012/05/01 01:57:55 UTC

Unable to import datetime in Jython UDF

Hi All,

I've been unable to import datetime to use in a Jython UDF. I found
the following thread and reverted from Jython 2.5.2 to 2.5.
Unfortunately that did not solve my problem.

I am running Pig 0.10.0 in local mode on my MacBook Pro. My Pig
classpath is pointing to jython.jar.


Any suggestions as to other things I should check? It sounds like this
should work.

Thanks, Chris


---------------------

Hey guys, thanks for the quick answers...

I've installed Jython 2.5 and that's what did the trick.

Thanks again! :)

On Thu, Apr 19, 2012 at 5:45 PM, kumar palaniappan <kp...@att.net> wrote:

> Sorry..I think I answered the wrong thread.
>
>
>
> ________________________________
> From: kumar palaniappan <kp...@att.net>
> To: user@pig.apache.org
> Sent: Thu, April 19, 2012 1:36:03 PM
> Subject: Re: Python UDF for piglatin script not finding re module
>
> I am using CDUH3 distribution and Pig is 0.8.
> I installed jython 2.2.1. Let me install jython 2.5.0 and see
>
> Devi
>
>
>
>
>
> ________________________________
> From: Gianmarco De Francisci Morales <g....@apache.org>
> To: user@pig.apache.org
> Sent: Thu, April 19, 2012 1:32:36 PM
> Subject: Re: Python UDF for piglatin script not finding re module
>
> Hi,
>
> welcome to the community!
>
> First question is, how did you install pig?
> Source or some other distribution?
>
> Second, Pig wants jython.version=2.5.0
> Which version have you installed?
>
> Cheers,
> --
> Gianmarco
>
>
>
> On Thu, Apr 19, 2012 at 21:29, Fernando Doglio <
> fernando.dog...@moove-it.com
> > wrote:
>
> > Hello everyone, new pig user here.
> >
> > I've being toying around with pig for a while now, and I wanted to create
> > my first UDF in Python. It all went fine until I wanted to use RegExps.
> >
> > I tried importing the "re" module on my python script, but when I did
> that,
> > I got an error message:
> >
> > [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1121: Python
> > Error. Traceback (most recent call last):
> >
> >  File "utils.py", line 3, in <module>
> >
> >    import re
> > ImportError: No module named re
> >
> >
> > Looking around the net, I ended up installing "jython" on my system, that
> > didn't do the trick, but doing a bit more research, I found out that the
> > sys.path variable was different when I ran the script using the "jython"
> > command and when I used the "pig" command:
> >
> > *Using Jython*
> >
> > ['', '/usr/share/jython/Lib', '/usr/lib/site-python', '__classpath__']
> >
> >
> > *Using pig*
> >
> > ['/pig/lib/Lib', '__classpath__', '__pyclasspath__/']1
> >
> >
> > So I went back to my script, and manually changed the "sys.path" variable
> > to look like the first example up there.. now when I run the script with
> > pig, I get the following message:
> >
> >  File "utils.py", line 8, in <module>
> >
> >    import re
> >  File "/usr/share/jython/Lib/re.py", line 7, in <module>
> >
> >    import sre, sys
> >  File "/usr/share/jython/Lib/sre.py", line 97, in <module>
> >
> >    import sre_compile
> >  File "/usr/share/jython/Lib/sre_compile.py", line 17, in <module>
> >
> >    assert _sre.MAGIC == MAGIC, "SRE module mismatch"
> > AssertionError: SRE module mismatch
> >
> >
> > According to someone on stackoverflow, this is due to the fact that my
> > manually installed "jython" version is different from the one used by
> > Pig....
> >
> > Now, finally, my question is: how do I get my python script to run on pig
> > correctly?
> >
> >
> > Thanks so much for reading and if you can, for answering!
> >
> > Fernando Doglio
> >
>

Re: Unable to import datetime in Jython UDF

Posted by Chris Diehl <cp...@gmail.com>.
Looks like I didn't have JYTHON_HOME set. That did the trick.

On Mon, Apr 30, 2012 at 4:57 PM, Chris Diehl <cp...@gmail.com> wrote:

> Hi All,
>
> I've been unable to import datetime to use in a Jython UDF. I found the following thread and reverted from Jython 2.5.2 to 2.5. Unfortunately that did not solve my problem.
>
> I am running Pig 0.10.0 in local mode on my MacBook Pro. My Pig classpath is pointing to jython.jar.
>
> Any suggestions as to other things I should check? It sounds like this should work.
>
> Thanks, Chris
>
> ---------------------
>
> Hey guys, thanks for the quick answers...
>
> I've installed Jython 2.5 and that's what did the trick.
>
> Thanks again! :)
>
> On Thu, Apr 19, 2012 at 5:45 PM, kumar palaniappan <kp...@att.net> wrote:
>
> > Sorry..I think I answered the wrong thread.
> >
> >
> >
> > ________________________________
> > From: kumar palaniappan <kp...@att.net>
> > To: user@pig.apache.org
> > Sent: Thu, April 19, 2012 1:36:03 PM
> > Subject: Re: Python UDF for piglatin script not finding re module
> >
> > I am using CDUH3 distribution and Pig is 0.8.
> > I installed jython 2.2.1. Let me install jython 2.5.0 and see
> >
> > Devi
> >
> >
> >
> >
> >
> > ________________________________
> > From: Gianmarco De Francisci Morales <g....@apache.org>
> > To: user@pig.apache.org
> > Sent: Thu, April 19, 2012 1:32:36 PM
> > Subject: Re: Python UDF for piglatin script not finding re module
> >
> > Hi,
> >
> > welcome to the community!
> >
> > First question is, how did you install pig?
> > Source or some other distribution?
> >
> > Second, Pig wants jython.version=2.5.0
> > Which version have you installed?
> >
> > Cheers,
> > --
> > Gianmarco
> >
> >
> >
> > On Thu, Apr 19, 2012 at 21:29, Fernando Doglio <
> > fernando.dog...@moove-it.com
> > > wrote:
> >
> > > Hello everyone, new pig user here.
> > >
> > > I've being toying around with pig for a while now, and I wanted to create
> > > my first UDF in Python. It all went fine until I wanted to use RegExps.
> > >
> > > I tried importing the "re" module on my python script, but when I did
> > that,
> > > I got an error message:
> > >
> > > [main] ERROR org.apache.pig.tools.grunt.Grunt - ERROR 1121: Python
> > > Error. Traceback (most recent call last):
> > >
> > >  File "utils.py", line 3, in <module>
> > >
> > >    import re
> > > ImportError: No module named re
> > >
> > >
> > > Looking around the net, I ended up installing "jython" on my system, that
> > > didn't do the trick, but doing a bit more research, I found out that the
> > > sys.path variable was different when I ran the script using the "jython"
> > > command and when I used the "pig" command:
> > >
> > > *Using Jython*
> > >
> > > ['', '/usr/share/jython/Lib', '/usr/lib/site-python', '__classpath__']
> > >
> > >
> > > *Using pig*
> > >
> > > ['/pig/lib/Lib', '__classpath__', '__pyclasspath__/']1
> > >
> > >
> > > So I went back to my script, and manually changed the "sys.path" variable
> > > to look like the first example up there.. now when I run the script with
> > > pig, I get the following message:
> > >
> > >  File "utils.py", line 8, in <module>
> > >
> > >    import re
> > >  File "/usr/share/jython/Lib/re.py", line 7, in <module>
> > >
> > >    import sre, sys
> > >  File "/usr/share/jython/Lib/sre.py", line 97, in <module>
> > >
> > >    import sre_compile
> > >  File "/usr/share/jython/Lib/sre_compile.py", line 17, in <module>
> > >
> > >    assert _sre.MAGIC == MAGIC, "SRE module mismatch"
> > > AssertionError: SRE module mismatch
> > >
> > >
> > > According to someone on stackoverflow, this is due to the fact that my
> > > manually installed "jython" version is different from the one used by
> > > Pig....
> > >
> > > Now, finally, my question is: how do I get my python script to run on pig
> > > correctly?
> > >
> > >
> > > Thanks so much for reading and if you can, for answering!
> > >
> > > Fernando Doglio
> > >
> >
>
>