Issue1318
Created on 2009-04-16.13:25:45 by doublep, last changed 2009-04-20.12:46:14 by doublep.
File name |
Uploaded |
Description |
Edit |
Remove |
LibImportTest.java
|
otmarhumbel,
2009-04-20.11:08:54
|
java main program |
|
|
test_lib_import.py
|
otmarhumbel,
2009-04-20.11:09:50
|
|
|
|
LibImportTest.sh
|
otmarhumbel,
2009-04-20.11:15:37
|
sample shell script to start the test in different ways |
|
|
msg4520 (view) |
Author: (doublep) |
Date: 2009-04-16.13:25:44 |
|
When a file executed with PythonInterpreter.execfile (InputStream,
String) contains the following line at the top:
from __future__ import with_statement
I get this error:
ImportError: No module named __future__
If this is executed using the standalone JAR, it works fine.
Maybe there is some other way to enable "future" features when running
scripts this way (i.e. with PythonInterpreter), but then I couldn't find
those.
|
msg4546 (view) |
Author: Oti Humbel (otmarhumbel) |
Date: 2009-04-20.11:09:50 |
|
.py file containing the import statement
|
msg4547 (view) |
Author: Oti Humbel (otmarhumbel) |
Date: 2009-04-20.11:15:37 |
|
As the attached sample shell script demonstrates, simply copying
jython.jar to another location and pointing the classpath to it will
work in the following cases:
1.
jython.jar is a standalone jar (which contains the /Lib folder)
2.
jython knows the path to the /Lib folder (using -Dpython.path in the
example)
|
msg4548 (view) |
Author: (doublep) |
Date: 2009-04-20.11:20:35 |
|
Thank you, I was trying to create a small example (I have a failure in a
huge webap), but couldn't reproduce it.
|
msg4549 (view) |
Author: Oti Humbel (otmarhumbel) |
Date: 2009-04-20.11:22:06 |
|
To summarize:
When using jython.jar not containing the /Lib folder, the path to /Lib
has to be specified.
(Special case: if the classpath points to an installed jython.jar,
jython guesses the correct path)
|
msg4550 (view) |
Author: (doublep) |
Date: 2009-04-20.11:22:43 |
|
However, in my webapp, I can import normal library modules, e.g. 'import
time' succeeds and works fine after that. I'm confused about what
'python.path' is actually for...
|
msg4551 (view) |
Author: Oti Humbel (otmarhumbel) |
Date: 2009-04-20.11:33:32 |
|
I was only guessing what your problem with __future__ was, and tried to
build a small example.
Web applications might be different, though.
Are you sure you really can import a module living in a .py file ?
(there is no physical time.py file, jython -v and 'import time' gives:
import: 'time' as org.python.modules.time.Time in builtin modules)
|
msg4552 (view) |
Author: (doublep) |
Date: 2009-04-20.11:49:40 |
|
Oh, indeed. I mostly use Java classes and just a few Python library
modules. When I try to import a non-builtin module I indeed get the
same ImportError, so yes, Jython is not configured properly...
I guess it's not a bug then?
|
msg4553 (view) |
Author: Oti Humbel (otmarhumbel) |
Date: 2009-04-20.11:55:57 |
|
doublep - thanks for your feedback!
Now closing as 'works for me'.
|
msg4554 (view) |
Author: (doublep) |
Date: 2009-04-20.12:46:14 |
|
One small improvement would be to give a more understandable error
message in such cases. But anyway, works here now. Thanks!
|
|
Date |
User |
Action |
Args |
2009-04-20 12:46:14 | doublep | set | messages:
+ msg4554 |
2009-04-20 11:55:57 | otmarhumbel | set | status: open -> closed resolution: works for me messages:
+ msg4553 |
2009-04-20 11:49:40 | doublep | set | messages:
+ msg4552 |
2009-04-20 11:33:33 | otmarhumbel | set | messages:
+ msg4551 |
2009-04-20 11:22:44 | doublep | set | messages:
+ msg4550 |
2009-04-20 11:22:06 | otmarhumbel | set | messages:
+ msg4549 |
2009-04-20 11:20:35 | doublep | set | messages:
+ msg4548 |
2009-04-20 11:15:37 | otmarhumbel | set | files:
+ LibImportTest.sh messages:
+ msg4547 |
2009-04-20 11:09:50 | otmarhumbel | set | files:
+ test_lib_import.py nosy:
+ otmarhumbel messages:
+ msg4546 |
2009-04-20 11:08:54 | otmarhumbel | set | files:
+ LibImportTest.java |
2009-04-16 13:25:45 | doublep | create | |
|