gotthardp / python-mercuryapi

Python wrapper for the ThingMagic Mercury API
MIT License
121 stars 62 forks source link

Unable to install library using pip #86

Closed Xzib closed 4 years ago

Xzib commented 4 years ago

While installing the library in windows, it is giving the following error

mercury.c:23:10: fatal error: tm_reader.h: No such file or directory

include

gotthardp commented 4 years ago

It feels you didn't download the Mercury API. Try to folllow the build instructions in README.

kenghzou95 commented 4 years ago

+1 unable to install the library using pip OS: ubuntu 18

gotthardp commented 4 years ago

The error also appears when xsltproc is not installed. Please make sure you have all software required to build it (see the documentation):

sudo apt-get install unzip patch xsltproc gcc libreadline-dev python-dev python-setuptools
clickworkorange commented 4 years ago

Another trap for young players: the installation will throw this error also if it runs out of space in /tmp. I know the space requirement is mentioned in the installation instructions (very helpful, thank you!), but not being one to read such things too carefully (I know!) I was initially stumped by fatal error: tm_reader.h: No such file or directory, and it took me a moment to find the true reason for it. The /tmp in my case is a tmpfs partition on a Pi3B, so nowhere near the required size. Installing with pip3 install python-mercuryapi -b /var/tmp got around the error (with /var/tmp being on disk microSD).

ahmedmibrahim commented 1 year ago

pip3 install python-mercuryapi -b /var/tmp still fails as well

pi@raspberrypi:~/python-mercuryapi $ pip3 install python-mercuryapi -b /var/tmp DEPRECATION: The -b/--build/--build-dir/--build-directory option is deprecated and has no effect anymore. pip 21.1 will remove support for this functionality. A possible replacement is use the TMPDIR/TEMP/TMP environment variable, possibly combined with --no-clean. You can find discussion regarding this at https://github.com/pypa/pip/issues/8333. Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple Collecting python-mercuryapi Using cached python-mercuryapi-0.5.3.tar.gz (21 kB) Building wheels for collected packages: python-mercuryapi Building wheel for python-mercuryapi (setup.py) ... error ERROR: Command errored out with exit status 1: command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-o5n00f6t/python-mercuryapi_6fcf76df24594a4eb2065aad8ac2c0ba/setup.py'"'"'; file='"'"'/tmp/pip-install-o5n00f6t/python-mercuryapi_6fcf76df24594a4eb2065aad8ac2c0ba/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-01ic_h8i cwd: /tmp/pip-install-o5n00f6t/python-mercuryapi_6fcf76df24594a4eb2065aad8ac2c0ba/ Complete output (25 lines): running bdist_wheel running build curl https://www.jadaktech.com/wp-content/uploads/2019/10/mercuryapi-1.31.1.36-2.zip -o mercuryapi-1.31.1.36-2.zip % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 88113 0 88113 0 0 49252 0 --:--:-- 0:00:01 --:--:-- 49225 unzip mercuryapi-1.31.1.36-2.zip Archive: mercuryapi-1.31.1.36-2.zip End-of-central-directory signature not found. Either this file is not a zipfile, or it constitutes one disk of a multi-part archive. In the latter case the central directory and zipfile comment will be found on the last disk(s) of this archive. unzip: cannot find zipfile directory in one of mercuryapi-1.31.1.36-2.zip or mercuryapi-1.31.1.36-2.zip.zip, and cannot find mercuryapi-1.31.1.36-2.zip.ZIP, period. make: *** [Makefile:23: mercuryapi-1.31.1.36/.done] Error 9 running build_ext building 'mercury' extension creating build creating build/temp.linux-armv7l-cpython-39 arm-linux-gnueabihf-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -ffile-prefix-map=/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Ibuild/mercuryapi/include -I/usr/include/python3.9 -c mercury.c -o build/temp.linux-armv7l-cpython-39/mercury.o mercury.c:23:10: fatal error: tm_reader.h: No such file or directory 23 | #include | ^~~~~ compilation terminated. error: command '/usr/bin/arm-linux-gnueabihf-gcc' failed with exit code 1

ERROR: Failed building wheel for python-mercuryapi Running setup.py clean for python-mercuryapi Failed to build python-mercuryapi Installing collected packages: python-mercuryapi Running setup.py install for python-mercuryapi ... error ERROR: Command errored out with exit status 1: command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-o5n00f6t/python-mercuryapi_6fcf76df24594a4eb2065aad8ac2c0ba/setup.py'"'"'; file='"'"'/tmp/pip-install-o5n00f6t/python-mercuryapi_6fcf76df24594a4eb2065aad8ac2c0ba/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-record-07ci9wp2/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/pi/.local/include/python3.9/python-mercuryapi cwd: /tmp/pip-install-o5n00f6t/python-mercuryapi_6fcf76df24594a4eb2065aad8ac2c0ba/ Complete output (23 lines): running install /home/pi/.local/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( running build unzip mercuryapi-1.31.1.36-2.zip Archive: mercuryapi-1.31.1.36-2.zip End-of-central-directory signature not found. Either this file is not a zipfile, or it constitutes one disk of a multi-part archive. In the latter case the central directory and zipfile comment will be found on the last disk(s) of this archive. unzip: cannot find zipfile directory in one of mercuryapi-1.31.1.36-2.zip or mercuryapi-1.31.1.36-2.zip.zip, and cannot find mercuryapi-1.31.1.36-2.zip.ZIP, period. make: *** [Makefile:23: mercuryapi-1.31.1.36/.done] Error 9 running build_ext building 'mercury' extension creating build creating build/temp.linux-armv7l-cpython-39 arm-linux-gnueabihf-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -ffile-prefix-map=/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Ibuild/mercuryapi/include -I/usr/include/python3.9 -c mercury.c -o build/temp.linux-armv7l-cpython-39/mercury.o mercury.c:23:10: fatal error: tm_reader.h: No such file or directory 23 | #include | ^~~~~ compilation terminated. error: command '/usr/bin/arm-linux-gnueabihf-gcc' failed with exit code 1

ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-o5n00f6t/python-mercuryapi_6fcf76df24594a4eb2065aad8ac2c0ba/setup.py'"'"'; file='"'"'/tmp/pip-install-o5n00f6t/python-mercuryapi_6fcf76df24594a4eb2065aad8ac2c0ba/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-record-07ci9wp2/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/pi/.local/include/python3.9/python-mercuryapi Check the logs for full command output.

clickworkorange commented 1 year ago

Your formatting is terrible, but I think pip is trying to unzip a 404 page; https://www.jadaktech.com/wp-content/uploads/2019/10/mercuryapi-1.31.1.36-2.zip does not exist any more, so the installer is curling an 88kb HTML page into a file called mercuryapi-1.31.1.36-2.zip. That won't work.

As it stands I think installing via pip is a no-go, and you have to build manually instead. Grab the latest release at https://github.com/gotthardp/python-mercuryapi/archive/refs/tags/v0.5.3.tar.gz and untar it to a folder, then download the mercuryapi ZIP file separately and place it in the python-mercuryapi folder. Then edit the Makefile setting for APIZIP to the name of the ZIP-file you downloaded before building.

DoongLi commented 1 year ago

@clickworkorange , Is there a detailed order? I don't know exactly how to do it

clickworkorange commented 1 year ago

@DoongLi

  1. Grab the latest release at https://github.com/gotthardp/python-mercuryapi/archive/refs/tags/v0.5.3.tar.gz
  2. Untar it to a folder
  3. Download the mercuryapi ZIP file separately and place it in the python-mercuryapi folder.
  4. Edit the Makefile setting for APIZIP to match the name of the ZIP-file you downloaded.
  5. Build the library with make.
  6. Install the library with sudo make install
rasdehya commented 6 months ago
10:42:29  |base|root@trixie python-mercuryapi-0.5.3 → make
unzip mercuryapi-1.31.1.36-2.zip
unzip:  cannot find or open mercuryapi-1.31.1.36-2.zip, mercuryapi-1.31.1.36-2.zip.zip or mercuryapi-1.31.1.36-2.zip.ZIP.
make: *** [Makefile:23 : mercuryapi-1.31.1.36/.done] Erreur 9

I downloaded the tar and zip version 0.5.3, put the zip in the python-mercury api folder, edit the Make file like so :

...
$(APIZIP): python-mercuryapi-0.5.3.zip

edit: I didn't see the first 2 lines, so i changed them too like this

APIZIP ?= python-mercuryapi-0.5.3.zip   
APIVER ?= 0.5.3

I say Replace All:

11:01:16  |base|root@trixie python-mercuryapi-0.5.3 → make
make: Dépendance circulaire python-mercuryapi-0.5.3.zip <- python-mercuryapi-0.5.3.zip abandonnée.
unzip python-mercuryapi-0.5.3.zip   
Archive:  python-mercuryapi-0.5.3.zip
ef5bff91acdb6f47855ea1446d1d942838a00ee6
replace python-mercuryapi-0.5.3/.gitignore? [y]es, [n]o, [A]ll, [N]one, [r]ename: A

and it gives me :

 extracting: python-mercuryapi-0.5.3/.gitignore  
  inflating: python-mercuryapi-0.5.3/.travis.yml  
  inflating: python-mercuryapi-0.5.3/LICENSE  
  inflating: python-mercuryapi-0.5.3/MANIFEST.in  
  inflating: python-mercuryapi-0.5.3/Makefile  
  inflating: python-mercuryapi-0.5.3/README.md  
  inflating: python-mercuryapi-0.5.3/long_description.txt  
  inflating: python-mercuryapi-0.5.3/mercury.c  
  inflating: python-mercuryapi-0.5.3/mercuryapi.patch  
  inflating: python-mercuryapi-0.5.3/mercuryapi.pyproj  
  inflating: python-mercuryapi-0.5.3/mercuryapi.sln  
  inflating: python-mercuryapi-0.5.3/mercuryapi_osx.patch  
  inflating: python-mercuryapi-0.5.3/setup-win.py  
  inflating: python-mercuryapi-0.5.3/setup.py  
  inflating: python-mercuryapi-0.5.3/test.py  
patch -p0 -d mercuryapi-0.5.3 < mercuryapi.patch
patch: **** Can't change to directory mercuryapi-0.5.3 : No such file or directory
make: *** [Makefile:24 : mercuryapi-0.5.3/.done] Erreur 2

see the Can't change to directory mercuryapi-0.5.3 : No such file or directory, so i change the name from python-mercuryapi-0.5.3 to mercuryapi-0.5.3.

and now i have:

11:07:18  |base|root@trixie mercuryapi-0.5.3 → make
make: Dépendance circulaire mercuryapi-0.5.3.zip <- mercuryapi-0.5.3.zip abandonnée.
unzip mercuryapi-0.5.3.zip  
Archive:  mercuryapi-0.5.3.zip
ef5bff91acdb6f47855ea1446d1d942838a00ee6
   creating: python-mercuryapi-0.5.3/
 extracting: python-mercuryapi-0.5.3/.gitignore  
  inflating: python-mercuryapi-0.5.3/.travis.yml  
  inflating: python-mercuryapi-0.5.3/LICENSE  
  inflating: python-mercuryapi-0.5.3/MANIFEST.in  
  inflating: python-mercuryapi-0.5.3/Makefile  
  inflating: python-mercuryapi-0.5.3/README.md  
  inflating: python-mercuryapi-0.5.3/long_description.txt  
  inflating: python-mercuryapi-0.5.3/mercury.c  
  inflating: python-mercuryapi-0.5.3/mercuryapi.patch  
  inflating: python-mercuryapi-0.5.3/mercuryapi.pyproj  
  inflating: python-mercuryapi-0.5.3/mercuryapi.sln  
  inflating: python-mercuryapi-0.5.3/mercuryapi_osx.patch  
  inflating: python-mercuryapi-0.5.3/setup-win.py  
  inflating: python-mercuryapi-0.5.3/setup.py  
  inflating: python-mercuryapi-0.5.3/test.py  
patch -p0 -d mercuryapi-0.5.3 < mercuryapi.patch
can't find file to patch at input line 3
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|--- c/src/api/Makefile 2015-10-06 04:39:20.000000000 -0700
|+++ c/src/api/Makefile 2016-07-30 02:44:13.854834003 -0700
--------------------------

I try all the steps before with $(APIZIP): ./mercuryapi-0.5.3 $(APIZIP): mercuryapi-0.5.3 or $(APIZIP): /home/$USER/mercuryapi-0.5.3/mercuryapi-0.5.3.zip and the same on the first line with APIZIP ?= mercuryapi-0.5.3, APIZIP ?= ./mercuryapi-0.5.3 or APIZIP ?= /home/$USER/mercuryapi-0.5.3

I also answer [A]ll or [N]one when asked

Sorry if it sound stupid, but it's the second time i ever do a make && make install ,

clickworkorange commented 5 months ago

In the folder python-mercuryapi (v0.5.4) I have the ZIP file mercuryapi-AHAB-1.35.2.72-1.zip. In the Makefile I have

APIZIP ?= mercuryapi-AHAB-1.35.2.72-1.zip
APIVER ?= 1.35.2.72

I open a terminal, cd to python-mercuryapi and type make. This builds the project without errors. A few suggestions that may help:

HTH!

lefty01 commented 5 months ago

in #142 I mentioned that I'm successfully using api 1.37.2 (also check this PR #148 ) maybe you could try that version as well ... ?

rasdehya commented 5 months ago

ok, that was a dumb thing for me in fact,.. i was using the code and the zip from the realease page. If i clone the repo everything works out the box.

So the 'latest' was not really the 'LATEST'.

So if it helps. just clone the repo. Modification has been made there