Code Monkey home page Code Monkey logo

Comments (4)

vladvrabie avatar vladvrabie commented on June 20, 2024 1

I had the same problem (I'm also on Windows). I got the package through pip and I saw that there are some differences in __init__.py compared to the one on github.

My downloaded __init__.py had in the decode method:
file_uri = 'file://' + quote(os.path.abspath(filename))

While on github it looks like this (link):
file_uri = pathlib.Path(filename).absolute().as_uri()

The version on github worked for me.

file_uri variable value in 1st case: file://D%3A%5Czxing_test%5Cimage.jpg
file_uri variable value in 2nd case: file:///D:/zxing_test/image.jpg

Maybe something needs to be updated on pypi?

from python-zxing.

zzll0909 avatar zzll0909 commented on June 20, 2024

image

from python-zxing.

dlenski avatar dlenski commented on June 20, 2024

Hmmm… I don't know either. The zxing Java binary is notably terrible at parsing the filenames sent to it by Python (it's possible that the Chinese characters in the path are confusing it). The fact that you're running on Windows doesn't help…

Can you try adding these two lines and re-running? It should print two extra lines with the filename and “file URI” before failing.

diff --git a/zxing/__init__.py b/zxing/__init__.py
index bd0dd31..c767f0a 100644
--- a/zxing/__init__.py
+++ b/zxing/__init__.py
@@ -58,7 +58,9 @@ class BarCodeReader(object):
         elif stdout.startswith(b'''Exception in thread "main" java.io.IOException: Could not load '''):
             raise BarCodeReaderException("Java library could not read image; is it in a supported format?", filename)
         elif stdout.startswith(b'''Exception '''):
+            print(filename)
+            print(file_uri)
             raise BarCodeReaderException("Unknown Java exception: %s" % stdout)
         elif p.returncode:
             raise BarCodeReaderException("Unexpected subprocess return code %d" % p.returncode, self.java)

from python-zxing.

dlenski avatar dlenski commented on June 20, 2024

The version on github worked for me.

I appreciate the feedback about the working change, but your way of demonstrating the difference is a little excruciating. 😓

A simple git log v0.10..HEAD will show you that we changed this in 06ce16c.

Maybe something needs to be updated on pypi?

Indeed. The aforementioned changes haven't yet been rolled into a release.

Update: Done. Latest version tagged as v0.11 and pushed to PyPI.

from python-zxing.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.