dayjaby / zebra-scanner

Read barcodes in python with zebra barcode scanner
MIT License
23 stars 18 forks source link

ImportError: dynamic module does not define module export function (PyInit_zebra_scanner) #7

Closed jbullara closed 3 years ago

jbullara commented 4 years ago

I'm not sure how to fix this error, after installing I can't seem to import the zebra scanner.

Traceback (most recent call last): File "test.py", line 4, in from zebra_scanner import CoreScanner ImportError: dynamic module does not define module export function (PyInit_zebra_scanner)

jamesthesnake commented 3 years ago

Also having this issue!

dayjaby commented 3 years ago

Did you install it via pip? Have you tried cloning the repo and running setup.py? Do you have Zebra SDK 4.4 installed?

kamilko commented 3 years ago

I'm also having this issue. And answering @dayjaby questions:

Currently I'm testing this on RaspberryPi, but this shouldn't be issue, as Zebra SDK is for arm. Device is properly installed in system as /dev/hidraw0 and accessible from user.

Other info might help:

[Edit] After manual python3 setup.py install --prefix=$HOME/.local I'm having following error:

New scanner found:
Error occured: <NULL>
<NULL>
Traceback (most recent call last):
  File "./test.py", line 11, in <module>
    @cs.on_scanner_added
  File "./test.py", line 14, in on_scanner_added
    pp.pprint(scanner.__dict__)
AttributeError: 'zebra_scanner.Scanner' object has no attribute '__dict__'

File test.py is just a minimal example from README.md.

So the issue from title is no more after manual installation, however it's hard to call it a fix. ;)

[Edit2] After removing both lines with pp.pprint(scanner.__dict__) no errors but also no output with scanned code by scanner.

cskowronnek commented 3 years ago

I removed both pp.pprint(scanner.dict) lines but I get a segmentation fault after scanning.

$ python3 test.py
New scanner found:
{'datatype': 'F', 'id': 0, 'permission': 7, 'value': True}
{'datatype': 'F', 'id': 1, 'permission': 7, 'value': False}
{'datatype': 'F', 'id': 2, 'permission': 7, 'value': False}
{'datatype': 'F', 'id': 3, 'permission': 7, 'value': True}
{'datatype': 'F', 'id': 4, 'permission': 7, 'value': False}
{'datatype': 'F', 'id': 5, 'permission': 7, 'value': False}
{'datatype': 'F', 'id': 6, 'permission': 7, 'value': True}
{'datatype': 'F', 'id': 7, 'permission': 7, 'value': False}
{'datatype': 'F', 'id': 8, 'permission': 7, 'value': True}
{'datatype': 'F', 'id': 9, 'permission': 7, 'value': False}
Scanned:
04261953 6
Segmentation fault
dayjaby commented 3 years ago

@cskowronnek Could you resolve this issue? Stepping through the execution with gdb might help.

cskowronnek commented 3 years ago

@dayjaby Does this help?

$ gdb -ex r --args python3 test.py
GNU gdb (Raspbian 8.2.1-2) 8.2.1
Copyright (C) 2018 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "arm-linux-gnueabihf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from python3...(no debugging symbols found)...done.
Starting program: /usr/bin/python3 test.py
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/libthread_db.so.1".
[Detaching after fork from child process 2733]
[Detaching after fork from child process 2736]
[Detaching after fork from child process 2749]
[Detaching after fork from child process 2752]
[Detaching after fork from child process 2755]
[Detaching after fork from child process 2759]
[Detaching after fork from child process 2765]
[New Thread 0x762a0460 (LWP 2773)]
[New Thread 0x758ff460 (LWP 2774)]
New scanner found: <9967A0DA45EC9A48BB839CF587393391>
{'datatype': 'F', 'id': 0, 'permission': 7, 'value': True}
Registering scanner -9967A0DA45EC9A48BB839CF587393391-
Scanned:
04261952 6

Thread 3 "python3" received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x758ff460 (LWP 2774)]
0x00111aa4 in PyErr_Fetch ()
(gdb)
(gdb) bt
#0  0x00111aa4 in PyErr_Fetch ()
#1  0x7669bb48 in pybind11::error_scope::error_scope (this=0x758fe648) at /usr/local/lib/python3.7/dist-packages/pybind11/include/pybind11/detail/common.h:769
#2  pybind11::class_<Barcode>::dealloc (v_h=...) at /usr/local/lib/python3.7/dist-packages/pybind11/include/pybind11/pybind11.h:1566
#3  0x766aac6c in pybind11::detail::clear_instance (self=0x762a3560) at /usr/local/lib/python3.7/dist-packages/pybind11/include/pybind11/detail/class.h:400
#4  pybind11::detail::pybind11_object_dealloc (self=0x762a3560) at /usr/local/lib/python3.7/dist-packages/pybind11/include/pybind11/detail/class.h:420
#5  0x76698470 in pybind11::handle::dec_ref() const & (this=0x758fe7cc) at /usr/local/lib/python3.7/dist-packages/pybind11/include/pybind11/pytypes.h:199
#6  pybind11::object::~object (this=0x758fe7cc, __in_chrg=<optimized out>) at /usr/local/lib/python3.7/dist-packages/pybind11/include/pybind11/pytypes.h:242
#7  CoreScanner::OnBarcodeEvent (this=<optimized out>, eventType=<optimized out>, pscanData=...) at /home/pi/zebra-scanner-master/src/BoostPythonCoreScanner.cpp:468
#8  0x766544e8 in EventListenerXmlImpl::OnBarcodeEvent(int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, unsigned char*, int, int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&) () from /usr/lib/zebra-scanner/corescanner/libcs-client.so
#9  0x766120a8 in ?? () from /usr/lib/zebra-scanner/corescanner/libcs-client.so
#10 0x76629bbc in boost::detail::thread_data<void (*)()>::run() () from /usr/lib/zebra-scanner/corescanner/libcs-client.so
#11 0x766612e8 in ?? () from /usr/lib/zebra-scanner/corescanner/libcs-client.so
#12 0x76f55494 in start_thread (arg=0x758ff460) at pthread_create.c:486
#13 0x76dc4578 in ?? () at ../sysdeps/unix/sysv/linux/arm/clone.S:73 from /lib/arm-linux-gnueabihf/libc.so.6
Backtrace stopped: previous frame identical to this frame (corrupt stack?)
dayjaby commented 3 years ago

@cskowronnek I see you use a Raspberry. Did you install the arm version of the Zebra SDK?

cskowronnek commented 3 years ago

@dayjaby Yes I do. It appears to be working fine when I check the corescanner logs

dayjaby commented 3 years ago

@cskowronnek can you check https://github.com/dayjaby/zebra-scanner/tree/fix_seg_fault:

git checkout fix_seg_fault
sudo python3 setup.py install
cskowronnek commented 3 years ago

Yay! It works!

dayjaby commented 3 years ago

:'D Writing code without actual hardware...closing this and let me know if you get any other issues.