Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.11 compatibility #26

Open
xulihang opened this issue Jun 19, 2023 · 7 comments
Open

Python 3.11 compatibility #26

xulihang opened this issue Jun 19, 2023 · 7 comments
Assignees

Comments

@xulihang
Copy link

Using the QR code detector under Python 3.11, I encountered the following error:

Traceback (most recent call last):
  File "D:\Python311\Lib\site-packages\flask\app.py", line 2190, in wsgi_app
    response = self.full_dispatch_request()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Python311\Lib\site-packages\flask\app.py", line 1486, in full_dispatch_request
    rv = self.handle_user_exception(e)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Python311\Lib\site-packages\flask_cors\extension.py", line 165, in wrapped_function
    return cors_after_request(app.make_response(f(*args, **kwargs)))
                                                ^^^^^^^^^^^^^^^^^^
  File "D:\Python311\Lib\site-packages\flask\app.py", line 1484, in full_dispatch_request
    rv = self.dispatch_request()
         ^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Python311\Lib\site-packages\flask\app.py", line 1469, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Python311\Lib\site-packages\flask_cors\decorator.py", line 128, in wrapped_function
    resp = make_response(f(*args, **kwargs))
                         ^^^^^^^^^^^^^^^^^^
  File "F:\git\Barcode-Reader-Aggregator\index.py", line 36, in read_barcodes
    response = reader.decode_bytes(bytes_decoded)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "F:\git\Barcode-Reader-Aggregator\barcode_reader\aggregated_reader.py", line 48, in decode_bytes
    results = self.reader.decode_bytes(file_bytes)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "F:\git\Barcode-Reader-Aggregator\barcode_reader\boofcv.py", line 33, in decode_bytes
    result_dict = self.decode_file(os.path.abspath("./temp/"+filename))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "F:\git\Barcode-Reader-Aggregator\barcode_reader\boofcv.py", line 21, in decode_file
    detector.detect(image)
  File "D:\Python311\Lib\site-packages\pyboof\recognition.py", line 349, in detect
    self.detections = [QrCode(x) for x in self.java_obj.getDetections()]
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Python311\Lib\site-packages\pyboof\recognition.py", line 349, in <listcomp>
    self.detections = [QrCode(x) for x in self.java_obj.getDetections()]
                       ^^^^^^^^^
  File "D:\Python311\Lib\site-packages\pyboof\recognition.py", line 311, in __init__
    self.corrected = mmap_array_java_to_python(jobj.corrected, MmapType.ARRAY_U8)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Python311\Lib\site-packages\pyboof\common.py", line 179, in mmap_array_java_to_python
    mm.seek(0)
    ^^^^^^^
AttributeError: 'NoneType' object has no attribute 'seek'
@xulihang xulihang changed the title Python 3.11 compability Python 3.11 compatibility Jun 19, 2023
@dushyant1singh1
Copy link

@xulihang I am facing the same issue in window environment.

@xulihang
Copy link
Author

I turned to the Java version in the end.

@dushyant1singh1
Copy link

Can you share the code for the java. I don't know much about java

@xulihang
Copy link
Author

I started an HTTP server in Java to communicate with a Python application. Here is the project: https://github.com/tony-xlh/Java-Barcode-Reader-Aggregator

@lessthanoptimal
Copy link
Owner

Working on this now. Unable to reproduce in 3.10 and building 3.11 from source. Will update once I can test that.

@lessthanoptimal
Copy link
Owner

lessthanoptimal commented Jul 3, 2023

Doesn't seem to be a problem with Python 3.11. Can anyone reproduce this in Ubuntu 20 or Ubuntu 22?

python --version
Python 3.11.4
python qrcode_detect.py
Detected a total of 1 QR Codes
Message: http://qrw.auvilfruit.com
     at: Polygon2D( (338.23473794244285,455.26204086572807) (394.7712536939371,491.4354170585221) (359.7815976084879,543.9501081705207) (302.569703805285,506.8517898530797) )

@xulihang
Copy link
Author

xulihang commented Jul 3, 2023

Maybe related to Java version?

openjdk version "11.0.10" 2021-01-19 LTS
OpenJDK Runtime Environment (build 11.0.10+9-LTS)
OpenJDK 64-Bit Server VM (build 11.0.10+9-LTS, mixed mode)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants