0

I'm using Adafruit_DHT library in a file and when I try to use pyinstaller to compile, I get an error that Raspberry_Pi_Driver.so: cannot open shared object file I'm using normal RPi (not model 2) and raspbian. The file that I'm trying to compile works by itself fine. The Raspberry_Pi_Driver.so is there I did find ./ | grep Raspberry_Pi_Driver.so and it existed. I tried also to use the --hidden-import=Adafruit_DHT when compiling the pyinsatller and that did not work too. When compiling it does not give any error. I noticed after compilation and in the build folder thee is an Adafruit_DHT folder that has the driver and etc. Any idea what's going on? Could it be that the library has been recreated under build folder and this is confusing when executing the file?

Hans
  • 104
  • 12
  • Set `LD_DEBUG` to see where the dynamic linker is looking for the .so? (http://www.bnikolic.co.uk/blog/linux-ld-debug.html). If it is not in the default path /lib /usr/lib etc. you may need to set LD_LIBRARY_PATH. – Pawel Aug 22 '16 at 04:02
  • You can try [this](http://stackoverflow.com/a/32048136/3837382) to point your code to the [`pyinstaller` temp directory](https://pythonhosted.org/PyInstaller/operating-mode.html#how-the-one-file-program-works). If this doesn't work try again with the `--hidden-import` option. – Repiklis Aug 22 '16 at 09:15
  • @Pawel: Can you show an example on how to set ld_debug? Is this when generating exe file or when executing it? – Hans Aug 22 '16 at 18:48
  • This is when executing. you can set it to all cat - e.g. `LD_DEBUG=all cat` but it will result with a lot of output. This is why I provided the link which contains options. – Pawel Aug 22 '16 at 19:38
  • It shows where it is looking at the .so file and I added that to the LD_LIBRARY_PATH but still got the same error. I'm gonna try @Repiklis's suggestion as this one is new – Hans Aug 22 '16 at 21:53
  • @Repiklis, are you suggesting to use --onefile? I already did that and it did not work and also dud it using the --hidden-import=modulename – Hans Aug 22 '16 at 21:59
  • When I used --onefile with --hidden-import option it gave the same error (cannot open shared...) but this time it is looking at a directory at /tmp/_XXXXX/Adafruit_DHT/driver.so. When I added that path to the LD_Library_path, it again gave the same error but this time it was looking at a different folder in the /tmp directory. It seems in every execution it looks at a different locaiton inside /tmp when I used --onefile to create this. – Hans Aug 22 '16 at 22:19
  • You don't "need" to use `--one-file`. I just assumed you did. If the file is there and your code is looking in the correct path it should work. Something else is amiss here. Can you post a [mcve](http://stackoverflow.com/help/mcve)? – Repiklis Aug 22 '16 at 22:50
  • OK, I found a resolution for this (learned from: http://k4ml.me/posts/pyinstaller.html) I just added -p /path/to/mylib when creating the exe file and mylib was the directory that Adafruit_DHT folder was (that Adafruit_DHT_Driver.so file was there). – Hans Aug 23 '16 at 01:39

1 Answers1

0

I found a resolution for this (thanks to: k4ml.me/posts/pyinstaller.html) I just added '-p /path/to/mylib' when creating the exe file and mylib was the directory that Adafruit_DHT folder was (that Adafruit_DHT_Driver.so file was there).

Hans
  • 104
  • 12