stepjam / PyRep

A toolkit for robot learning research.
MIT License
695 stars 165 forks source link

PyRep in Google Colab #168

Closed ycps closed 4 years ago

ycps commented 4 years ago

Hello, I have trying to run CoppeliaSim+PyRep on Google Colab, but ran into issues. The full ipynb is reproduced below:

!wget 'https://coppeliarobotics.com/files/CoppeliaSim_Edu_V4_0_0_Ubuntu18_04.tar.xz'
!tar -xf 'CoppeliaSim_Edu_V4_0_0_Ubuntu18_04.tar.xz'

import os
COPPELIASIM_ROOT = '/content/CoppeliaSim_Edu_V4_0_0_Ubuntu18_04'
os.environ['COPPELIASIM_ROOT'] = COPPELIASIM_ROOT
os.environ['LD_LIBRARY_PATH'] += f':{COPPELIASIM_ROOT}'
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = COPPELIASIM_ROOT

!git clone https://github.com/stepjam/PyRep.git
%cd PyRep
%pip install -r requirements.txt
!python setup.py install --user
%cd /content

import pyrep # triggers error

error:

/root/.local/lib/python3.6/site-packages/pyrep/backend/sim.py in <module>()
      1 from .simConst import *
----> 2 from ._sim_cffi import ffi, lib
      3 import numpy as np
      4 import collections
      5 

ImportError: libcoppeliaSim.so.1: cannot open shared object file: No such file or directory

Which is odd, because we can confirm that the file/link exists:

os.path.exists(os.path.join(os.environ['COPPELIASIM_ROOT'], 'libcoppeliaSim.so.1'))
# True
nanbaima commented 4 years ago

Good question!

Skylion007 commented 4 years ago

Setting the LD_LIBRARY_PATH inside of collab won't affect the currently running python process, only newly spawned python and other subprocesses. (Doing !python -c 'import pyrep' should load the library correctly). You can solve that issue at least by doing a more aggressive install and copy the shared libraries directly into the currently loaded library path like so:

from distutils.dir_util import copy_tree
copy_tree(COPPELIASIM_ROOT, '/usr/lib/')
stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.