Using python OBD in jython
dia986 opened this issue · comments
Hi,
I am trying to use this package with jython. I already installed it in my jython site-packages. Whenever I run a script that has the line "import obd" I get the following error message:
File "test.py", line 2, in
import obd
File "C:\jython2.7.1\Lib\site-packages\obd_init_.py", line 41, in
from .obd import OBD
File "C:\jython2.7.1\Lib\site-packages\obd\obd.py", line 38, in
from .commands import commands
File "C:\jython2.7.1\Lib\site-packages\obd\commands.py", line 35, in
from .OBDCommand import OBDCommand
File "C:\jython2.7.1\Lib\site-packages\obd\OBDCommand.py", line 33, in
from .utils import *
File "C:\jython2.7.1\Lib\site-packages\obd\utils.py", line 39, in
import serial
File "C:\jython2.7.1\Lib\site-packages\serial_init_.py", line 33, in
from serial.serialjava import Serial
File "C:\jython2.7.1\Lib\site-packages\serial\serialjava.py", line 38, in
comm = detect_java_comm([
File "C:\jython2.7.1\Lib\site-packages\serial\serialjava.py", line 32, in detect_java_comm
raise ImportError("No Java Communications API implementation found")
ImportError: No Java Communications API implementation found
Any idea on how to run this package with jython? Any suggestion would be greatly appreciated.
Thanks!
anyone here?
@dia986 Your problem is that your Java installation does not actually have the "Java Communications API" libraries, javax.comm.*
, which Java needs in order to talk to serial ports. It seems like Oracle got bored of them and stopped including them in its Java releases (or never shipped them by default to begin with). Also, Oracle seems to only have the current version for Linux.
A bunch of people on StackOverflow were scratching their heads over this about a decade ago, and they were passing around some links to old versions and install instructions.
It looks like gnu.io.*
can also be used by PySerial when running on Jython; that is the "RXTX" library. The best Windows builds I think are put out by whoever runs Fizzed.com. You can download the right ZIP for your Java (depending on if you have 32-bit or 64-bit Java), and follow the included Install.txt
instructions to copy the files into your Java installation. To do that, you need to figure out where your Java installation actually is (i.e. what JAVA_HOME
ought to be). I think you can do set JAVA_HOME
at the Windows command prompt, or type %JAVA_HOME%
into the location bar in the file manager, or maybe do where java
at the command prompt and then go up to the folder holding the bin
folder that Java itself is in.