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

"sys.path.insert" error #19

Open
texx00 opened this issue Mar 8, 2020 · 9 comments
Open

"sys.path.insert" error #19

texx00 opened this issue Mar 8, 2020 · 9 comments

Comments

@texx00
Copy link

texx00 commented Mar 8, 2020

I tried to load the library by using sys.path.insert but there was an error at runtime:
File "main.py", line 6, in <module> import VL53L0X
File "/home/pi/*MyPath*/lib/VL53L0X_rasp_python/python/VL53L0X.py", line 68, in <module> tof_lib = CDLL("../bin/vl53l0x_python.so")
File "/usr/lib/python3.5/ctypes/__init__.py", line 347, in __init__ self._handle = _dlopen(self._name, mode)
OSError: ../bin/vl53l0x_python.so: cannot open shared object file: No such file or directory

I tried to add the path to the libraries environment variable and other things but I was not able to fix it.

I did find a workaround by changing the VL53L0X.py library file like this on line 67:
# Load VL53L0X shared lib
import os
dirname = os.path.dirname(__file__)
filename = os.path.join(dirname, "../bin/vl53l0x_python.so")
tof_lib = CDLL(filename)

I've never worked/used ctypes and I'm sure this is not the best solution but I cannot understand if I'm doing something wrong or if it is really a library issue.

@MohammedKhaliid
Copy link

I have the same issue here and can't solve it too, so have you found any solution to that?

@texx00
Copy link
Author

texx00 commented Sep 30, 2021

To make it work I needed to change it like this:

I did find a workaround by changing the VL53L0X.py library file like this on line 67:

import os 
dirname = os.path.dirname(__file__)
filename = os.path.join(dirname, "../bin/vl53l0x_python.so")
tof_lib = CDLL(filename)```

@MohammedKhaliid
Copy link

Traceback (most recent call last):
  File "VL53L0X.py", line 71, in <module>
    tof_lib = CDLL(filename)
  File "/usr/lib/python3.7/ctypes/__init__.py", line 356, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: ../bin/vl53l0x_python.so: cannot open shared object file: No such file or directory

Almost the same error after the editing !!

could you help me with that?

@texx00
Copy link
Author

texx00 commented Sep 30, 2021

Are you building the library with make? Check if you have the .so file in the bin folder... This is the only idea I have

@MohammedKhaliid
Copy link

I didn't find the .so file in bin folder although I have made all the steps mentioned in the post, so do you have any idea how to add this file and solve this problem?
Thanks in advance

@texx00
Copy link
Author

texx00 commented Sep 30, 2021

You need to be sure the make command is running correctly and the file should be created automatically. I never worked with ctypes thus I do not know more than this. Make is compiling the library from c code into the .so file. You may look around for more info about make... Maybe you can change some options or enable some logging... Not sure though

@MohammedKhaliid
Copy link

Ok, thank you for your help.

@Gerrit404
Copy link

To make it work I needed to change it like this:

I did find a workaround by changing the VL53L0X.py library file like this on line 67:

import os 
dirname = os.path.dirname(__file__)
filename = os.path.join(dirname, "../bin/vl53l0x_python.so")
tof_lib = CDLL(filename)```

Thanks! I had issues using this package as a subfolder in my program. My executing main is two folders above this package folder. By adjusting the VL53L0X.py with your settings it works

@DansDesigns
Copy link

DansDesigns commented Jan 13, 2024

I tried the solution mentioned above but that didnt work for me (NanoPi Neo) so i put the explicit path into line 67:

# Load VL53L0X shared lib
tof_lib = CDLL("/home/pi/VL53L0X_rasp_python/bin/vl53l0x_python.so")

and this seemed to work however i now get the following issue:

VL53L0X Start Ranging Object 0 Address 0x29

Call of VL53L0X_DataInit
API Status: -20 : Control Interface Error
Timing 20 ms
Call of VL53L0X_StopMeasurement
API Status: -20 : Control Interface Error

solved it by switching to another sensor..

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

No branches or pull requests

4 participants