问题标签 [jpype]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
python - Ctrl-C 结束我的脚本,但它没有被 KeyboardInterrupt 异常捕获
我有一个 Python 脚本,其中包含一个读取文件并做一些事情的大循环(我正在使用几个包,如 urllib2、httplib2 或 BeautifulSoup)。
它看起来像这样:
问题是程序在我点击Ctrl+时停止,C但它没有被我的两个 KeyboardInterrupt 异常中的任何一个捕获,尽管我确信它当前处于循环中(因此至少在大 try/except 内)。
这怎么可能?起初我认为这是因为我正在使用的一个包没有正确处理异常(比如只使用“except:”),但如果是这样的话,我的脚本就不会停止。但是脚本确实停止了,它应该至少被我的两个人抓住,对吧?
我哪里错了?
提前致谢!
编辑:
通过在 try-except 之后添加一个finally:
子句并在两个 try-except 块中打印回溯,它通常None
在我点击Ctrl+时显示C,但我曾经设法得到这个(似乎它来自 urllib2,但我不知道是否这就是我无法捕捉键盘中断的原因):
回溯(最近一次通话最后):
python - JPype 和 JayDeBeAPI:AttributeError:'property' 对象没有属性 'isBeanAccessor'
在尝试通过 JDBC 连接到数据库时,我构建了 JPype (JPype1-0.5.5.4) 和 JayDeBeAPI 0.1.4。这是在 RHEL 上。我可以使用驱动程序成功连接,
但是当我执行 SQL 时,我在 JPype 中得到了这个回溯:
我不知道从哪里开始,而且似乎找不到任何提到这个问题的东西。
jpype - 在 JPype 中关闭 JVM 后调用 JVM 中创建的变量
我在 JVM 中创建了一个 hashmap 并想在 jpype.shutdownJVM 之后访问它,我该怎么做?
我知道 dict 在 python 中用作 hashmap,我尝试过:
jpype.startJVM(jpype.getDefaultJVMPath(),"-Djava.class.path=%s" % classpath) hashmap = jpype.java.util.HashMap() ...#insert pairs jpype.shutdownJVM() ... hashmap ["key"] 这不起作用。
谢谢。
python - 使用 JPype-total 新手查询从 Python 调用 jar 文件
所以我一直在使用 subprocess.call从 Python运行一个jar文件,如下所示:
它将结果写入外部 output_file 文件。-a是一个选项。
我现在想在 python 中分析 output_file 但想避免再次打开文件。所以我想将jarFile.jar作为 Python 函数运行,例如:
我已经安装了 JPype 并让它工作,我已经设置了类路径并启动了 JVM 环境:
我现在卡住了......
python - JPype 和 JayDeBeAPI 返回 jpype._jclass.java.lang.Long
我在 PySpark(Apache Spark Python API)中使用JayDeBeAPI,这是我的代码的开头(注意,我实际上是通过带有 PySpark 的交互式 shell 运行所有这些)。
我正在查询Apache Phoenix,它是 Apache HBase 的 SQL“前端”。
这是我用于 SQL 查询的 Python 代码:
对于所有行,我得到的输出都是这样的:
如何修复它以便它实际显示返回的列(count
列)的值?
从Apache Phoenix 数据类型页面,该count
列的数据类型是 BIGINT,它被映射到java.lang.Long
,但由于某种原因jpype
没有显示结果。
python setup.py install
当我下载它们时,我得到了 JayDeBeAPI 0.1.4 和 JPype 0.5.4.2 。
java - JPype / Java - Initialize with, or get, remaining heap space
We have software written in Python, which uses JPype to call Java, which performs various resource heavy calculations / report building. We originally assigned 800mb of heap space when starting the JVM. The java side is fully multithreaded and will work with whatever resources are available to it.
This worked well until we tested on Windows XP for our legacy clients. The new machines are Win 7 64-bit with 4GB of RAM, whereas the old ones are Win XP 32-bit with only 2 GB of ram.
The issue is that JPype causes our application to ungracefully and silently crash if we allocate too much memory. A try catch doesn't even get triggered on the statement above.
I'm wondering if there's a way to use java from command line to determine how much memory we can allocate on a computer. We can check if it's 32-bit or 64-bit which helps, but we need to make sure they aren't running other programs taking up heap space on the JVM. If they are, our application will crash.
Reader's Digest: We'd like to allocate 500mb of heap space when initializing the JVM, but can't be sure of how much space is currently being used. If we allocate too much, the entire application silently crashes.
We use the following JPype: 0.5.4.2 Python: 2.7 Java: 1.8 or 1.7 (64-bit or 32-bit)
Thanks.
java - Jpype 将参数传递给 Java
我有一个带有以下行的java程序员
程序从外部 jar 中调用类和方法。
我想在 python 中编写等效代码,它像我的 java 程序一样调用外部 jar。使用 Jpype 我实现了代码,但在下一行失败了
这里的 PropertySet、ItemSchema 是我从外部 jar 中使用的类。ItemSchema.Subject 和 ewsPkg.ItemSchema.Body 是类类型
运行代码我在上面提到的线上得到以下错误 -
谢谢
python - 如何安装带有 .whl 文件的 Python 包?
我在我的 Windows 机器上安装 Python 包时遇到问题,我想用 Christoph Gohlke 的 Window 二进制文件安装它。(根据我的经验,这减轻了许多其他软件包安装的麻烦)。但是,只有 .whl 文件可用。
http://www.lfd.uci.edu/~gohlke/pythonlibs/#jpype
但是如何安装 .whl 文件?
笔记
- 我在 wheel 上找到了文档,但它们在解释如何安装 .whl 文件时似乎并不那么直截了当。
- 这个问题与这个问题重复,没有直接回答。
python - 创建列表使用 JPype
我试图通过 JPype 访问它的方法,在我的 python 代码中使用斯坦福解析器。这是我的相关(python3.4)代码:
Java 代码(来自 stanford 解析器)中的函数 parseStrings 如下所示:
我收到的错误消息:
我对Java的了解非常有限。我猜这个错误消息试图告诉我我传递给它的参数类型不正确。如果这确实是错误的,那么显然“jpype._jclass.java.util.ArrayList”与 List(String) 不匹配(这里的意思是 lessThan,greaterThan,但在帖子中表现不佳)。如果尝试将(python)列表中的字符串显式添加为(java)字符串,如下所示:jpype.java.lang.String(t)(见评论)。但是我收到了同样的错误信息。
有人可以告诉我我在这里做错了什么吗?
java - Lucene 内存使用
我正在索引约 250.000 个文档,但在 200.000 左右后达到 OOME(在此之前,它变得非常慢,直到达到 GC 限制)。
代码如下所示(我使用的是 jpype):
我希望文档和字段会被刷新,然后每隔一段时间进行一次垃圾收集,所以应该不可能命中 OOME。相反,似乎某处有泄漏。如何确定这是否是 lucene 或 jpype 的问题?假设这是一个 lucene 问题,我有什么可能减少内存使用?我可以诊断冲洗发生的频率或类似情况吗?