Can't find python module

Ryan Schmidt ryandesign at macports.org
Sat Jan 10 10:22:37 PST 2015


On Jan 10, 2015, at 7:43 AM, James Rome wrote:

> I am trying to use j2py. But it keeps asking for the antlr3 module. I
> installed antlr3 and py-antlr3, but it is still not finding them.
> ....
>    from java2python.compiler import template, visitor
>  File
> "/Library/Python/2.7/site-packages/java2python/compiler/template.py",
> line 20, in <module>
>    from java2python.lang import tokens
>  File "/Library/Python/2.7/site-packages/java2python/lang/__init__.py",
> line 7, in <module>
>    from java2python.lang.JavaLexer import JavaLexer as Lexer
>  File
> "/Library/Python/2.7/site-packages/java2python/lang/JavaLexer.py", line
> 4, in <module>
>    from antlr3 import *
> ImportError: No module named antlr3
> 
> I have
> export
> PYTHONPATH="/opt/local/Library/Frameworks/Python.framework/Versions/2.7/site-packages":$PYTHONPATH
> export PYTHON=/opt/local/bin/python
> 
> Note that there is no site-packages directory!


The mention of "/Library/Python" in your output above makes me think you aren't using MacPorts' version of python27. Either run /opt/local/bin/python2.7 directly or use "port select python python27" to make /opt/local/bin/python a symlink to it.

I'm not familiar with j2py, but if it's this:

https://code.google.com/p/java2python/source/browse/trunk/bin/j2py

then its first line of "#!/usr/bin/env python" means it is running "python", wherever that is in your PATH, so using "port select" as above should help it to run MacPorts' python instead of OS X's python.



More information about the macports-users mailing list