jython

Using multiprocessing 2.6.2.1 package in Jython

烂漫一生 提交于 2019-12-05 23:16:58
I'm new to Jython/Python world. I'm trying to install the multiprocessing package in Jython. However I'm getting following return message from the easy_install Setup script exited with error: Compiling extensions is not supported on Jython Is there any way I can install this package in Jython? You can't use it if multiprocessing requires C extensions i.e., if you can't disable them and the module was not reimplemented for Jython in Java/pure Python. multiprocessing module is included in the stdlib since Python 2.6. Current Jython supports Python 2.5. There is no GIL in Jython so you can use

Memory Limit for Jython

こ雲淡風輕ζ 提交于 2019-12-05 23:00:39
How can I set the JVM memory limit (-Xmx option for Java) for my Jython program? I understand that Jython 2.5 introduces the -J option in order to send options to the JVM: jython -J-Xmx8000m However, I have to work with Jython 2.2a0 on java1.6.0_23 , which does not have that option. You could just edit jython.bat (windows) or jython (Linux) and add it. "C:\...\java.exe" -Dpython.home="C:\..." -classpath "C:\... to "C:\...\java.exe" -Xmx1024m -Dpython.home="C:\..." -classpath "C:\... You could set environment variables JAVA_OPTIONS (for jython < 2.5) or JAVA_MEM for jython 2.5 e.g.: alias

Running Python modules in Python, from Jython

大憨熊 提交于 2019-12-05 19:19:15
I have been dropped into a complicated environment, where I am working with a Python library but everything else we have is in Java. We want to be able to access and use the Python library from Java, so we started researching and using Jython. Jython is pretty great, and we are importing the Jython Interpreter into our Java program so that we can access most of the library. However, Jython doesn't quite support everything, and there's not much we can do to get around that. All the paths are set up correctly and there are some modules that we just can't import. So assuming that there's nothing

Jython - javaos.getenv() gives “Failed to get environment, environ will be empty”

与世无争的帅哥 提交于 2019-12-05 19:07:46
I'm wondering if anyone ran into this problem. Whenever I run any jython program in Eclipse, I got the following error in the beginning of the output: " Failed to get environment, environ will be empty: (0, 'Failed to execute command ([\'sh\', \'-c\', \'env\']): java.io.IOException: Cannot run program "sh": Crea teProcess error=2, The system cannot find the file specified') First, my environment is: Windows 2008 JDK 1.6.0u10 jython 2.2.1 I did some digging, and I realized that this message is produced in the function javaos.getenv(). Whenever I call the javaos.getenv() function, it throws the

Howto multithreaded jython scripts running from java?

℡╲_俬逩灬. 提交于 2019-12-05 18:14:48
问题 I'm constructing a framework in Java that will listen for events and then process them in Jython. Different event types will be sent to different scripts. Since jython takes quite some time to compile the script when PythonInterpreter.exec() is called, I will have to pre-compile the scripts. I'm doing it the following way: // initialize the script as string (would load it from file in final version) String script = "print 'foo'"; // get the compiled code object PyCode compiled = org.python

Unresolved import org.python / working with jython and java?

◇◆丶佛笑我妖孽 提交于 2019-12-05 16:52:43
I'm using Eclipse and I"m trying to create a java program that can run my python code. I'm following the guidelines on this page: http://jythonpodcast.hostjava.net/jythonbook/en/1.0/JythonAndJavaIntegration.html#using-jython-within-java-applications But when I include these statements at the top: package org.jython.book.util; import org.python.core.PyObject; import org.python.core.PyString; import org.python.util.PythonInterpreter; I receive a message saying "The import org.python cannot be resolved." Any suggestions on how to fix this? Thank you so much!! In the Package Explorer (on the left)

Jython: subprocess.Popen runs out of file descriptors

允我心安 提交于 2019-12-05 15:30:45
I'm using the Jython 2.51 implementation of Python to write a script that repeatedly invokes another process via subprocess.Popen and uses PIPE to pipe stdout and stderr to the parent process and stdin to the child process. After several hundred loop iterations, I seem to run out of file descriptors. The Python subprocess documentation mentions very little about freeing file descriptors, other than the close_fds option, which isn't described very clearly (Why should there be any file descriptors besides 0, 1 and 2 open in the first place?). I'm assuming that in CPython, reference counting

Developing Eclipse plugins without Java

岁酱吖の 提交于 2019-12-05 10:58:35
Is it possible to create Eclipse plugins/program Eclipse RCP apps without Java? (preferably in Jython) This will be possible in the next Eclipse major release e4: One of the goals of e4 is to provide support for writing plugins in other languages. The quote is from http://wiki.eclipse.org/E4/JavaScript which summarizes the current state of using javascript to implement eclipse plug-ins in e4. This issue in eclipse's bugzilla issue #227058 also has some discussion on that, but I believe it is outdated. I am currently not aware of activity regarding other languages. No. An Eclipse plugin is an

How to speed up this Python code?

走远了吗. 提交于 2019-12-05 09:29:08
I've got the following tiny Python method that is by far the performance hotspot (according to my profiler, >95% of execution time is spent here) in a much larger program: def topScore(self, seq): ret = -1e9999 logProbs = self.logProbs # save indirection l = len(logProbs) for i in xrange(len(seq) - l + 1): score = 0.0 for j in xrange(l): score += logProbs[j][seq[j + i]] ret = max(ret, score) return ret The code is being run in the Jython implementation of Python, not CPython, if that matters. seq is a DNA sequence string, on the order of 1,000 elements. logProbs is a list of dictionaries, one

sqlite3 module for Jython

回眸只為那壹抹淺笑 提交于 2019-12-05 08:06:14
I'm using Java Scripting API to execute some external Python scripts from my Java application. The python scripts use sqlite3 module. Execution of the application is resulting in error ImportError: No module named sqlite3 As I look into the Lib directory(which is in the classpath) of Jython, there's no sqlite3 module. Hence, my search begins and I found one _sqlite3.py file which is an implementation of javasqlite ( http://bugs.jython.org/issue1682864 ). It's use produced more similar kind of errors. Then I searched the original python's sqlite3 package(original directory) from the python's