dayjaby / zebra-scanner

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

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 #6

Closed pyshawon closed 3 years ago

pyshawon commented 4 years ago

Hi, i'm getting an issue while installing zebra-scanner

i have installed zebra core scanner sdk for Linux. also i have installed all the dependency. but when i apply "sudo pip install zebra-scanner" install command. i'm getting an error. ERROR:

/usr/include/boost/python/class.hpp:583:5: required from ‘boost::python::class<T, X1, X2, X3>::class(const char, const char) [with W = CoreScanner; X1 = boost::python::detail::not_specified; X2 = boost::python::detail::not_specified; X3 = boost::python::detail::not_specified]’ /tmp/pip-build-5c4Zqk/zebra-scanner/src/BoostPythonCoreScanner.cpp:32:35: required from here /usr/include/boost/python/converter/as_to_python_function.hpp:21:17: error: invalid abstract parameter type ‘CoreScanner’ static void convert_function_must_take_value_or_const_reference(U()(T), int, T = 0) {} ^~~~~~~~~~~ error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------

Command "/usr/bin/python -u -c "import setuptools, tokenize;file='/tmp/pip-build-5c4Zqk/zebra-scanner/setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" install --record /tmp/pip-9KuH1Q-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-5c4Zqk/zebra-scanner/

i'm using Linux mint 19.2.

JustinMBrown commented 4 years ago

I'm having the same issue. Did you ever figure it out? @dayjaby

ewendeng commented 4 years ago

me too.

jerrylogansquare commented 4 years ago

me too, i did notice when I try to use dpkg to install the corescanner deb on ubuntu, i get the following errors, I don't know if its related

jerry.morrow@us-d17-0134:~/Downloads/SDK_for_Linux_v4.4.1-2_Debian_Packages_x86_64bit_C98$ sudo dpkg -i zebra-scanner-corescanner_4.4.1-2_amd64.deb (Reading database ... 276805 files and directories currently installed.) Preparing to unpack zebra-scanner-corescanner_4.4.1-2_amd64.deb ... zebra-scanner-devel depdnds on zebra-scanner-corescanner dpkg: warning: subprocess old pre-removal script returned error exit status 255 dpkg: trying script from the new package instead ... zebra-scanner-devel depdnds on zebra-scanner-corescanner dpkg: error processing archive zebra-scanner-corescanner_4.4.1-2_amd64.deb (--install): subprocess new pre-removal script returned error exit status 255 Udev rule was found udeadm command found in your system success reloading udev rules success triggering new rules Processing triggers for libc-bin (2.23-0ubuntu11) ... Errors were encountered while processing: zebra-scanner-corescanner_4.4.1-2_amd64.deb

rbarzic commented 4 years ago

I confirm the issue - But my first error message is the following : /usr/include/boost/python/object/value_holder.hpp:62:11: error: cannot declare field ‘boost::python::objects::value_holder::m_held’ to be of abstract type ‘CoreScanner’ Value m_held; (Ubuntu 18.04.04 LTS)

Forgot to mentionned the SDK used: SDK_for_Linux_v4.4.1-8_Debian_Packages_x86_64bit_C98

(Same issue with the C11 SDK )

I also try the master version of zebra-scanner (the one that uses pybind11). And there is an absctract class issue that leads me to think that the SDK may have change the API.

It would be nice to know with SDK version has been used

pyshawon commented 4 years ago

@rbarzic I have tried to fix the issue but it not working. then I use pyusb to access Scanner. I did for Linux and Windows now I'm struggling for macOS. here is some sample code that can help. check the python code:

https://gist.github.com/pyshawon/26f5e6ca948b475d4e219978e9eed186

rbarzic commented 4 years ago

@pyshawon : thanks for sharing. Unfortunatly, I don't have a scanner with me right now - But I'll definitively look into your code if I can't manage to get the zebra-scanner module to work

dayjaby commented 4 years ago

I confirm the issue - But my first error message is the following : /usr/include/boost/python/object/value_holder.hpp:62:11: error: cannot declare field ‘boost::python::objects::value_holder::m_held’ to be of abstract type ‘CoreScanner’ Value m_held; (Ubuntu 18.04.04 LTS)

Forgot to mentionned the SDK used: SDK_for_Linux_v4.4.1-8_Debian_Packages_x86_64bit_C98

(Same issue with the C11 SDK )

I also try the master version of zebra-scanner (the one that uses pybind11). And there is an absctract class issue that leads me to think that the SDK may have change the API.

It would be nice to know with SDK version has been used

@rbarzic Which boost python version are you using? I just tried it here on a fresh computer and it compiles perfectly. I push a small change, where it makes sure that the correct pybind11 is installed. If you do sudo pip install pybind11, it should find it.

And there is an absctract class issue that leads me to think that the SDK may have change the API.

Please put the file from the PR https://github.com/dayjaby/zebra-scanner/pull/2/files into .../zebra-scanner/src. As you can see, it's copyrighted and I could not find a way to include it simply in the code.

rbarzic commented 4 years ago

@dayjaby - Thanks - I'll give it a try , probably next week unfortunatly. But I notice one thing: Your class definition is missing the OnBinaryDataEvent method

/**

I think that explains my issue with the master branch. You are probably using an older SDK

dayjaby commented 4 years ago

@rbarzic You are right! I think I've written the code for 4.1, but it compiles fine when adding this virtual function! Added it to master branch and to pypi. Thank you so much for reporting the issue :)

I think I should mention somewhere for which zebra sdk versions it's supposed to be working.

rbarzic commented 4 years ago

Excellent ! - I can confirm that the module can be installed on Ubuntu 18.04.4 LTS (on 2 PCs). Couldn't try it with a scanner as I don't have access to it right now

Thank you !

sohamshah93 commented 4 years ago

@dayjaby There is a problem when installing zebra-scanner for windows because there is an error Failed building wheel for zebra-scanner and I have installed pybind11 library. I really need help for my project and thank you again for developing this module.

dayjaby commented 4 years ago

@dayjaby There is a problem when installing zebra-scanner for windows because there is an error Failed building wheel for zebra-scanner and I have installed pybind11 library. I really need help for my project and thank you again for developing this module.

I dont develop on windows, so I cant really help you there. But what you can do: in the setup.py are the specific zebra sdk paths for linux. You could try to replace them with the correct windows paths and run python setup.py install

rbarzic commented 4 years ago

I have now access to a scanner so I can test the latest version. Unfortunatly, it fails immediatly : Traceback (most recent call last): File "./myzebra.py", line 4, in from zebra_scanner import CoreScanner ImportError: dynamic module does not define module export function (PyInit_zebra_scanner)

I've installed the latest sdk version from source (zebra-scanner-4.4.1-8.tar.gz).

Any clue ? (I'm using python3 and the zebra.scanner package was installed in a python3 virtual environement)

PS: I look into the setup file - is this a python2 module only ?

dayjaby commented 4 years ago

@rbarzic Updated master branch for python3 support. For me it was necessary to clean the previous zebra scanner files:

sudo rm -rf /usr/local/lib/python3.6/dist-packages/zebra_scanner*

Edit: Just so that we are on the same line, you use Ubuntu 18.04 with Python3.6?

rbarzic commented 4 years ago

Well I have python3.6 and 3.7 installed (3.6 being the default for python3). So I'm using virtual environement to get the correct version of Python.

python --version Python 3.6.9

pip freeze pybind11==2.5.0 zebra-scanner @ file:///home/roba/perso/github/zebra-scanner (<- points to "master")

I get now:

raceback (most recent call last):
  File "./zebraScanner.py", line 8, in <module>
    cs = CoreScanner()
AttributeError: 'zebra_scanner.Scanner' object has no attribute '__dict__'

I think there is something fishy with pybind11 and multiple versions of python being installed

dayjaby commented 4 years ago

This error does not sound too bad: It means at least that the code is working up to this line:

o.attr("__dict__").attr("update")(s.get_dict());

I don't remember the exact purpose of this line, but I think it was for being able to access each scanner like a dictionary to retrieve model number, firmware version, etc.

I don't have a zebra scanner available right now so I cannot test up to this line. But feel free to try things out, e.g.

  1. comment the line
  2. Try o.attr("__dict__") = s.get_dict();
rbarzic commented 4 years ago

@dayjaby - Thanks - Actually the issue looks like it was related to a permission error (I've changed PC while debugging the issue) - Now, it looks like I have an error in the void CoreScanner::FetchScanners() function - eStatus is not equal to STATUS_OK so the code returns silently. In which mode are you using the scanner BTW ? (and I guess you need the cscored.service to be stopped ?)

rbarzic commented 4 years ago

Thanks - Removing access to dict removes the errors - But it don't seems the test.py is working as expected - I don't get call back on barcode scanned (and I have no id/datatype/value/premission printed

rbarzic commented 4 years ago

Apparently the string to be used for CMD_REGISTER_FOR_EVENTS should be:

 std::string inXml = "<inArgs><cmdArgs><arg-int>6</arg-int><arg-int>1,2,4,8,16,32</arg-int></cmdArgs></inArgs>";

Only six possible values are supported according to the documentation (I got an error code 109 otherwise). I still can't have the scanner working - I have this error now: terminate called after throwing an instance of 'pybind11::cast_error' what(): make_tuple(): unable to convert arguments to Python object (compile in debug mode for details)

I'll try to debug further

dayjaby commented 4 years ago

@rbarzic I will order the module again as well (Zebra SE4750MR + PL3307C000R); I think fixing the code should not be too hard - when I worked on it 2 years ago, it took me about one night to get it working. Do you have any deadline?

rbarzic commented 4 years ago

No hard deadline - I'm trying to setup this package for some summer students that have started to work at my company. All the changes I have made so far are here https://github.com/rbarzic/zebra-scanner. As I mentionned above I end up in an pybind11::cast_error : terminate called after throwing an instance of 'pybind11::cast_error' what(): make_tuple(): unable to convert argument of type 'std::auto_ptr' to Python object

To be more precise: I got the correct barcode value in CoreScanner::OnBarcodeEvent (I have added some print statement) - but the s.OnBarcode(b); fails because of something wrong happening in call_python on the ret = fn(arg1); line

Update : Apparently the problem comes from the fact that my USB scanner is actually reported as two scanners (didn't have time to dig into that) with differents properties. If I exclude the "scanner" that does not have attributes with id below 10, then I got the test.py example to work correctly.

See https://github.com/rbarzic/zebra-scanner/blob/master/examples/test.py

2nd update: apparently, trying test.py on another PC is not working - back to the cast_error exception - I'll have to investigate more

Final update : I've fixed the cast error in my fork - works ok on two different PCs running Ubuntu 18.04

dayjaby commented 4 years ago

Awesome job! Feel free to make a PR and I would be happy to merge it :)

herrlustig commented 4 years ago

Thank you for updating on this issue.

I got the same issue on ubuntu 18.04 with python3.6. I also used the sdk 4.4.1. Hm, if it works for SDK version 4.1.x, .. do you know where I can find this version ? on the official zebra developer page I only can see the newest one (4.4.1)

dayjaby commented 4 years ago

Hey @rbarzic . Is it fine for you if I apply your changes to the master branch? Other folks are fetting the same errors.

rbarzic commented 4 years ago

👍

On Fri, Jun 26, 2020, 11:21 David Jablonski notifications@github.com wrote:

Hey @rbarzic https://github.com/rbarzic . Is it fine for you if I apply your changes to the master branch? Other folks are fetting the same errors.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dayjaby/zebra-scanner/issues/6#issuecomment-650081210, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGGD4UEGRUQAPEUFCJSQCDRYRSB5ANCNFSM4JKWRKIA .

andrewshvv commented 3 years ago

@dayjaby Is it fixed in final version (commit: d497feb7f2ab825131708e68d8e5f828faaa6f70)? For some reason I still have it, wonder whether the fix was applied or not.

dayjaby commented 3 years ago

@andrewshvv which version of zebra SDK do you have installed?

andrewshvv commented 3 years ago

@dayjaby

SDK: SDK_for_Linux_v4.4.1-15_Debian_Packages_x86_64bit_C98.zip
OS: Ubuntu 20.04.1 LTS

You can find all additional info about my installation in this thread

dayjaby commented 3 years ago

Closing this. Feel free to reopen if the issue still remains.