Comments (4)
Hello,
I tried to debug with a friend what is happening...
It seems the function "bcr.decode" is not working properly when running on terminal on a graphical environment.
But we don't know how to make it work.
We added a print behind bc definition:
print("**",bcr.decode(ff))
bc = bcr.decode(ff, try_harder=args.try_harder)
this is working through ssh:
zxing /home/user/alb0008.tiff
** BarCode(raw='1234|000', parsed='1234|000', path='/home/user/alb0008.tiff', format='PDF_417', type='TEXT', points=[(2425.0, 814.0), (2426.0, 925.0), (2914.0, 816.0), (2914.0, 926.0), (2494.0, 814.0), (2495.0, 925.0), (2840.0, 816.0), (2841.0, 926.0)])
/home/user/alb0008.tiff
======================
Decoded TEXT barcode in PDF_417 format.
Raw text: '1234|000'
Parsed text: '1234|000'
and this output is through graphical:
zxing /home/user/alb0008.tiff
/home/user/alb0008.tiff
======================
Traceback (most recent call last):
File "/usr/local/bin/zxing", line 8, in <module>
sys.exit(main())
^^^^^^
File "/usr/local/lib/python3.11/site-packages/zxing/__main__.py", line 66, in main
if not bc:
^^
UnboundLocalError: cannot access local variable 'bc' where it is not associated with a value
line 66 is not real, because we added more comments to the code
from python-zxing.
I have different output running the command from ssh and from graphical....
๐คจ
Are you sure you are running the same version of ZXing both via ssh and via the local "graphical" terminal? I'm skeptical.
I'm guessing that in at least one place, you're running a version of python-zxing
that does not include the bugfix in 980a045.
from python-zxing.
Hello, thank you for taking your time to look over my question.
After lot of changes I'm going to uninstall everything and start from zero:
#pip3.11 uninstall zxing
Found existing installation: zxing 1.0
Uninstalling zxing-1.0:
Would remove:
/usr/local/bin/zxing
/usr/local/lib/python3.11/site-packages/zxing-1.0.dist-info/*
/usr/local/lib/python3.11/site-packages/zxing/*
Proceed (Y/n)? y
Successfully uninstalled zxing-1.0
# locate zxing
/usr/local/bin/zxing
/usr/local/lib/python3.11/site-packages/zxing
/usr/local/lib/python3.11/site-packages/zxing-1.0.dist-info
# updatedb
# locate zxing
# pip3.11 cache purge
Files removed: 3
Now I'm going to install it again with python 3.11. When issue was open, zxing was installed with python3.9
# pip3.11 install zxing --proxy http://192.168.x.x:8080
Collecting zxing
Downloading zxing-1.0-py3-none-any.whl (680 kB)
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ 680.1/680.1 kB 3.5 MB/s eta 0:00:00
Installing collected packages: zxing
Successfully installed zxing-1.0
now let's see line 52 in main.py:
48 else:
49 ff = fn
50
51 try:
52 bc = bcr.decode(ff, try_harder=args.try_harder)
53 except BarCodeReaderException as e:
54 p.error(e.message + ((': ' + e.filename) if e.filename else '') + (('\n\tCaused by: ' + repr(e.__cause__) if e.__cause__ else '')))
there is no "bc=none", so I added it in line 52 and running zxing command through ssh and graphical terminal
so:
48 else:
49 ff = fn
50
51 bc = None
52 try:
53 bc = bcr.decode(ff, try_harder=args.try_harder)
54 except BarCodeReaderException as e:
ssh:
# zxing /alb0001.tiff
/alb0001.tiff
=============
Decoded TEXT barcode in PDF_417 format.
Raw text: '1234|000'
Parsed text: '1234|000'
gnome-terminal:
# zxing /alb0001.tiff
/alb0001.tiff
=============
ERROR: Failed to decode barcode (using Java ZXing library v3.5.1).
I think is failing to decode barcode because "bcr.decode" function is not working in graphical... ( test made in answer 2 )
EDIT: add "print("**",bcr.decode(ff))" to test:
ssh:
#zxing /alb0001.tiff
** BarCode(raw='1234|000', parsed='1234|000', path='/alb0001.tiff', format='PDF_417', type='TEXT', points=[(1372.0, 791.0), (1372.0, 901.0), (1860.0, 794.0), (1861.0, 902.0), (1441.0, 791.0), (1442.0, 901.0), (1787.0, 794.0), (1787.0, 902.0)])
/alb0001.tiff
=============
Decoded TEXT barcode in PDF_417 format.
Raw text: '1234|000'
Parsed text: '1234|000'
gnome-terminal
# zxing /alb0001.tiff
/alb0001.tiff
=============
ERROR: Failed to decode barcode (using Java ZXing library v3.5.1).
from python-zxing.
Ok, I think I have found the problem:
Trying messing with python in graphical terminal:
>>> barcode = reader.decode("/alb0001.tiff")
RuntimeError: b'Exception in thread "main" java.lang.UnsatisfiedLinkError: Can\'t load library: /usr/lib/jvm/java-11-openjdk-11.0.16.1.1-1.el9_0.x86_64/lib/libawt_xawt.so\n\tat java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2633)\n\tat java.base/java.lang.Runtime.load0(Runtime.java:768)\n\tat java.base/java.lang.System.load(System.java:1837)\n\tat java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)\n\tat java.base/java.lang.ClassLoader$NativeLibrary.load(ClassLoader.java:2445)\n\tat java.base/java.lang.ClassLoader$NativeLibrary.loadLibrary(ClassLoader.java:2501)\n\tat java.base/java.lang.ClassLoader.loadLibrary0(ClassLoader.java:2700)\n\tat java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2651)\n\tat java.base/java.lang.Runtime.loadLibrary0(Runtime.java:830)\n\tat java.base/java.lang.System.loadLibrary(System.java:1873)\n\tat java.desktop/java.awt.Toolkit$3.run(Toolkit.java:1399)\n\tat java.desktop/java.awt.Toolkit$3.run(Toolkit.java:1397)\n\tat java.base/java.security.AccessController.doPrivileged(Native Method)\n\tat java.desktop/java.awt.Toolkit.loadLibraries(Toolkit.java:1396)\n\tat java.desktop/java.awt.Toolkit.<clinit>(Toolkit.java:1429)\n\tat java.desktop/sun.awt.AppContext$2.run(AppContext.java:282)\n\tat java.desktop/sun.awt.AppContext$2.run(AppContext.java:271)\n\tat java.base/java.security.AccessController.doPrivileged(Native Method)\n\tat java.desktop/sun.awt.AppContext.initMainAppContext(AppContext.java:271)\n\tat java.desktop/sun.awt.AppContext$3.run(AppContext.java:326)\n\tat java.desktop/sun.awt.AppContext$3.run(AppContext.java:309)\n\tat java.base/java.security.AccessController.doPrivileged(Native Method)\n\tat java.desktop/sun.awt.AppContext.getAppContext(AppContext.java:308)\n\tat java.desktop/javax.imageio.spi.IIORegistry.getDefaultInstance(IIORegistry.java:129)\n\tat java.desktop/javax.imageio.ImageIO.<clinit>(ImageIO.java:66)\n\tat com.google.zxing.client.j2se.ImageReader.readImage(ImageReader.java:44)\n\tat com.google.zxing.client.j2se.DecodeWorker.decode(DecodeWorker.java:125)\n\tat com.google.zxing.client.j2se.DecodeWorker.call(DecodeWorker.java:76)\n\tat com.google.zxing.client.j2se.CommandLineRunner.main(CommandLineRunner.java:99)\n'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.11/site-packages/zxing/__init__.py", line 129, in decode
raise BarCodeReaderException("Unknown Java exception", self.java) from RuntimeError(stdout)
zxing.BarCodeReaderException: ('Unknown Java exception', 'java')
After this error I upgrade "java-11-openjdk" and now is working both ssh and gnome-terminal
from python-zxing.
Related Issues (20)
- Cannot install from tarball HOT 1
- Command-line interface HOT 4
- data matrix generator HOT 1
- Fix TravisCI test failure for python 3.7, 3.8
- read multiple barcodes? HOT 3
- raw and parsed decode compatibility with ZXing HOT 5
- Use jpype for wrapper? HOT 2
- how to get rawByte from qr code? HOT 2
- How to input image array instead of filename to read QR code? HOT 3
- utf-8 codec decoding error HOT 3
- How to get QR Code version, error correction level, and mask? HOT 4
- Can't find the code when there are other content in the image HOT 1
- Different results from online decoder HOT 2
- ZXing does not decode some QR images HOT 2
- Issues in decoding PDF 417 format Barcodes HOT 2
- Can't install ZXing - FileNotFoundError "requirements.txt" HOT 13
- what's the difference between raw and parsed results? HOT 1
- Java binary specified does not exist HOT 2
- utf-8 encoding problem, ???????? instead of Thai letters HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-zxing.