jpype

Cannot install JPype on ubuntu 12.04 64 bit

百般思念 提交于 2019-12-11 06:16:24
问题 Well, I followed the instructions here, but I get a compilation error when running setup.py src/native/common/jp_voidtype.cpp: In member function ‘virtual void JPVoidType::setArrayValues(jarray, HostRef*)’: src/native/common/jp_voidtype.cpp:105:2: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings] cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for Ada/C/ObjC but not for C++ [enabled by default] cc1plus: warning: command line option ‘-Wstrict

JPype (Python): importing folder of jar's

梦想与她 提交于 2019-12-11 06:13:54
问题 i am using JPype in order to work with java classes in python. I have a folder that contains multiple self-written .jar files. I know how to import multiple .jar's on the long way: ... CLASSPATH = "/path/to/jars/first.jar:/path/to/jars/second.jar" jpype.startJVM(jpype.getDefaultJVMPath(), "-ea", "-Djava.class.path=%s" % CLASSPATH) MYLIB= jpype.JPackage("org").mylib MyClass = MYLIB.MyClass myObj = MyClass() This works fine, but i think there might be a better way. I already tried this:

Segmentation fault when starting jvm using jpype

眉间皱痕 提交于 2019-12-11 05:35:49
问题 I am trying to use java sutime in my Python code. The code has been working fine until yesterday but now ends with Segmentation fault. The problem seems to be coming from jpype.startJVM(getDefaultJVMPath()) This function ends with Segmentation fault. The defaultJVMPath is '/usr/lib/jvm/java-8-oracle/jre/lib/amd64/server/libjvm.so' I have tried uninstalling and then installing java and jpype. The code works fine in virtual box with less memory, so the problem doesnt seems to be coming from

Calling a jar file from Python using JPype-total newbie query

感情迁移 提交于 2019-12-06 20:53:27
So I have been using subprocess.call to run a jar file from Python as so: subprocess.call(['java','-jar','jarFile.jar',-a','input_file','output_file']) where it writes the result to an external output_file file. and -a is an option. I now want to analyse output_file in python but want to avoid opening the file again. So I want to run jarFile.jar as a Python function, like: output=jarFile(input_file) I have installed JPype and got it working, I have set the class path and started the JVM environment: import jpype classpath="/home/me/folder/jarFile.jar" jpype.startJVM(jpype.getDefaultJVMPath(),"

Installing jpype in Mountain Lion

梦想的初衷 提交于 2019-12-03 14:24:17
I am trying to install jpype in Mountain Lion. I followed all the steps suggested in this post: How to install JPype on OS X Lion to use with Neo4j? However, there is a glitch with Mountain Lion. I have modified the setupMacOSX() function as follows: /Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/JavaVM.framework/ But when I run $ sudo python setup.py install I get the following error: src/native/common/include/jpype.h:45:10: fatal error: 'jni.h' file not found I have located the jni.h header here: /System/Library/Frameworks/JavaVM.framework/Versions/A/Headers/jni.h But since jni.h

ubuntu下pycharm调用Hanlp实践分享

自闭症网瘾萝莉.ら 提交于 2019-12-02 16:35:03
前几天看了大快的举办的大数据论坛峰会的现场直播,惊喜的是hanlp2.0版本发布。Hanlp2.0版本将会支持任意多的语种,感觉还是挺好的!不过更多关于hanlp2.0的信息,可能还需要过一段时间才能看到,只能等一下了!下面分享一篇大神的文章,是关于在ubuntu下使用pycharm调用hanlp的实验。 以下为全文: 首先点击File,选择Settings,在Project 下点击Project Interpreter,并通过点击右边的加号: 搜索JPype,根据python版本选择你需要的JPype版本安装。 之后,在https://github.com/hankcs/HanLP/releases 网站下载hanlp.jar包、模型data包、配置文件hanlp.properties,新建一个文件夹Hanlp, 把hanlp.jar和hanlp.properties放进去;之后需要再新建一个文件夹hanlp,并将data放进去; 修改Hanlp下的路径为当前data的路径,由于我将data放在/home/javawork/hanlp下,因此:root=/home/javawork/hanlp/ 接下来新建一个文件demo_hanlp.py,代码如下: #! /usr/bin/env python2.7 #coding=utf-8 from jpype import * #

Practical use of Java class/JAR in Python?

亡梦爱人 提交于 2019-12-02 04:33:34
问题 I spent significant amount of time looking for this and explore many solutions. This is related to this thread. Calling Java from Python In the end, after testing: Pyjnius : Cannot install in Windows. Py4J: can install on windows, but using Gateway is a bit heavy. JPype: Python 3 installed in 5 mins, can load 50Mo JAR without any issues. Good thing is the syntax is completely merged with Python syntax... https://github.com/tcalmant/jpype-py3 Just Wondering, if any people has developed real

Practical use of Java class/JAR in Python?

僤鯓⒐⒋嵵緔 提交于 2019-12-02 01:37:34
I spent significant amount of time looking for this and explore many solutions. This is related to this thread. Calling Java from Python In the end, after testing: Pyjnius : Cannot install in Windows. Py4J: can install on windows, but using Gateway is a bit heavy. JPype: Python 3 installed in 5 mins, can load 50Mo JAR without any issues. Good thing is the syntax is completely merged with Python syntax... https://github.com/tcalmant/jpype-py3 Just Wondering, if any people has developed real world wrapping application of Java in Python (ie running on a production server) with big size JAR ? To

hanlp在Python环境中的安装失败后的解决方法

爷,独闯天下 提交于 2019-11-30 03:17:39
Hanlp是由一系列模型与算法组成的javag工具包,目标是普及自然语言处理再生环境中的应用。有很多人在安装hanlp的时候会遇到安装失败的情况,下面就是某大神的分享的在python环境中安装失败的解决方法,大家可以借鉴学习以下! 由于要使用hanlp进行分词,而我们的环境是python环境所以得安装pyhanlp,但是安装过程总是出现这样的问题 看上去感觉是缺少了visual c++环境,于是安装visual c++,可查看这个博客www.hankcs.com/nlp/python-calls-hanlp.html 安装完后发现问题并没有解决,初步怀疑应该是 jpype1没有安装成功,于是使用pip install jpype1发现果然失败,最终手动安装pip install D:\soft\JPype1-0.6.2-cp36-cp36m-win_amd64.whl 安装成功。 安装包地址:www.lfd.uci.edu/~gohlke/pythonlibs/#jpype 注意如果出现 JPype1-0.6.3-cp36-cp36m-win_amd64.whl is not a supported wheel on this platform.可看如下搭配更换版本: cp27 → CPython 2.7 cp34 → CPython 3.4 cp35 → CPython 3.5

在Python中调用Java扩展包HanLP测试记录

会有一股神秘感。 提交于 2019-11-30 03:08:18
最近在研究中文分词及自然语言相关的内容,关注到JAVA环境下的HanLP,HanLP是一个致力于向生产环境普及NLP技术的开源Java工具包,支持中文分词(N-最短路分词、CRF分词、索引分词、用户自定义词典、词性标注),命名实体识别(中国人名、音译人名、日本人名、地名、实体机构名识别),关键词提取,自动摘要,短语提取,拼音转换,简繁转换,文本推荐,依存句法分析(MaxEnt依存句法分析、神经网络依存句法分析)。 由于自己才疏学浅,对JAVA方面了解不多,所以打算在Python环%2, line 5, in <module> startJVM(getDefaultJVMPath()) File “C:\Python27\lib\site-packages\jpype\_core.py”, line 44, in startJVM _jpype.startup(jvm, tuple(args), True) RuntimeError: First paramter must be a string or unicode at src/native/python/jpype_module.cpp:31 很有可能是没有配置JDK的环境变量或安装的JDK的位数与Python的位数不一致。导致 getDefaultJVMPath() 方法返回的是 None。 下载HanLP (1