cmbruns / pyopenvr

Unofficial python bindings for Valve's OpenVR virtual reality SDK
BSD 3-Clause "New" or "Revised" License
251 stars 40 forks source link

Linux - expects to find 64bit library #26

Closed mungewell closed 5 years ago

mungewell commented 7 years ago

SteamVR can be installed under the Linux client, looks like pyopenvr expects library to be 64bit... when it isn't (at least on my machine).

simon@morkmobile:~/pyopenvr-git$ python src/samples/hello.py
Traceback (most recent call last):
  File "src/samples/hello.py", line 5, in <module>
    import openvr
  File "/usr/local/lib/python2.7/dist-packages/openvr/__init__.py", line 39, in <module>
    _openvr = cdll.LoadLibrary(_openvr_lib_name)
  File "/usr/lib/python2.7/ctypes/__init__.py", line 440, in LoadLibrary
    return self._dlltype(name)
  File "/usr/lib/python2.7/ctypes/__init__.py", line 362, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libopenvr_api_64.so: cannot open shared object file: No such file or directory
simon@morkmobile:~/pyopenvr-git$ dpkg --list | grep steam
ii  steam-launcher                         1.0.0.53                                      all          Launcher for the Steam software distribution service
simon@morkmobile:~/pyopenvr-git$ find ~/.local/ -name 'libopenvr*'
/home/simon/.local/share/Steam/ubuntu12_32/libopenvr_api.so
cmbruns-hhmi commented 7 years ago

The file "libopenvr_api_64.so" should be installed with pyopenvr, in the same folder as init.py. The openvr project provides only a 64-bit linux library; no 32-bit version at the moment. https://github.com/ValveSoftware/openvr/tree/master/bin PyOpenVR uses its own copy of the openvr api shared library, so it would match the exact version of the API wrapped by the python binding.

I wonder whether setting LD_LIBRARY_PATH could help sidestep this problem.

Did you install pyopenvr via "pip install pyopenvr"?

Are you running 64-bit python?

Sorry I have not been testing pyopenvr on Linux. Your help in sorting out these issues is appreciated.

eric-schleicher commented 7 years ago

I'm interested in getting this to work as well. Attempting to create a ros node based on this library.

Am i understanding it correctly that i would need to make a copy of the libopenvr_api_64.so file in the same folder as this library?

willing to try.

Please advise.

cmbruns commented 7 years ago

@eric-schleicher Are you trying to use pyopenvr on a 32-bit linux system? That's what this issue is about.

If you have somehow obtained a 32-bit openvr shared library, you could experiment with naming it libopenvr_api_32.so, and placing it in the pyopenvr folder. Unfortunately pyopenvr has not been well tested even on 64-bit linux systems. But you might find some enlightenment in issue #5 https://github.com/cmbruns/pyopenvr/issues/5#issuecomment-245012925

Have you at least got regular C++ openvr code working on your linux machine, and are now trying to get pyopenvr working?

eric-schleicher commented 7 years ago

No sorry this will be x64. I've gotten steamVR to work (barely; only on fresh boot). at the moment it all seems a bit brittle.

I'm weighing writing the ros node as a receiver from a windows system (that would stream the tracked object telemetry over), or attempting to run steamVR natively on (same as ros) linux (brittle-robot?) .

eric-schleicher commented 7 years ago

ok, i did end up running into this exact despite being on x64 ubuntu 16.04LTS and useing python3.5 with pip3 to perform the install.

image

I was able to get it to run on windows; and i was just reproducing the logical steps on linux, which is my target platform.

Now following the comment on issue #5. will update if i find a solution

claytmcneil commented 7 years ago

I ran into an issue loading the library as well. The problem is that the mechanism used to load the library does not look at PATH, but rather looks at LD_LIBRARY_PATH. However, since that particular variable has to be set before python is invoked, there's not way (that I can tell) to set it in the script.

So rather than trying to set a PATH, I just changed the script to use an absolute path when on Linux.

kazoo-kmt commented 7 years ago

Hi @claytmcneil, I'm having a trouble including the PATH (I described the detail here https://github.com/cmbruns/pyopenvr/issues/5#issuecomment-310237824). Could you share the process you took in detail and the potential solution for this issue?

claytmcneil commented 7 years ago

@kazoo-kmt Rather then set the PATH, I specified the full path of the lib in the open. Under openvr/init.py, I modified last line of the snippet below:

# Add current directory to PATH, so we can load the DLL from right here. os.environ['PATH'] += os.pathsep + os.path.dirname(__file__) _openvr = cdll.LoadLibrary(os.path.join("/absolute/path/to/library", _openvr_lib_name))

cmbruns commented 5 years ago

Fixed by fix for #36