dtamayo / reboundx

A library for adding additional forces to the REBOUND N-body integration package
GNU General Public License v3.0
80 stars 60 forks source link

"OSError: librebound.cpython-37m-x86_64-linux-gnu.so: cannot open shared object file: No such file or directory" when importing reboundx on Google Colab #87

Closed rcanalese closed 1 year ago

rcanalese commented 1 year ago

Hello, I have been trying to use rebound and reboundx in a Google Colab notebook, but I keep getting the following error:

import reboundx

OSError                                   Traceback (most recent call last)

[<ipython-input-5-44515272dadb>](https://localhost:8080/#) in <module>
----> 1 import reboundx

2 frames

[/usr/local/lib/python3.7/dist-packages/reboundx/__init__.py](https://localhost:8080/#) in <module>
     11 pymodulespath = os.path.dirname(__file__)
     12 from ctypes import *
---> 13 clibreboundx = cdll.LoadLibrary(pymodulespath + '/../libreboundx' + suffix)
     14 
     15 # Version

[/usr/lib/python3.7/ctypes/__init__.py](https://localhost:8080/#) in LoadLibrary(self, name)
    440 
    441     def LoadLibrary(self, name):
--> 442         return self._dlltype(name)
    443 
    444 cdll = LibraryLoader(CDLL)

[/usr/lib/python3.7/ctypes/__init__.py](https://localhost:8080/#) in __init__(self, name, mode, handle, use_errno, use_last_error)
    362 
    363         if handle is None:
--> 364             self._handle = _dlopen(self._name, mode)
    365         else:
    366             self._handle = handle

OSError: librebound.cpython-37m-x86_64-linux-gnu.so: cannot open shared object file: No such file or directory

I could share an example notebook if it helps, but the only other thing I've done is run pip install rebound reboundx. Is there any workaround, or is the library incompatible with Google Colab?

dtamayo commented 1 year ago

Hm, that’s strange. Yes, would you mind sharing a notebook? I was just doing this last week

On Sun, Oct 16, 2022 at 5:46 PM rcanalese @.***> wrote:

Hello, I have been trying to use rebound and reboundx in a Google Colab notebook, but I keep getting the following error:

import reboundx

OSError Traceback (most recent call last)

in ----> 1 import reboundx

2 frames

/usr/local/lib/python3.7/dist-packages/reboundx/init.py in 11 pymodulespath = os.path.dirname(file) 12 from ctypes import * ---> 13 clibreboundx = cdll.LoadLibrary(pymodulespath + '/../libreboundx' + suffix) 14 15 # Version

/usr/lib/python3.7/ctypes/init.py in LoadLibrary(self, name) 440 441 def LoadLibrary(self, name): --> 442 return self._dlltype(name) 443 444 cdll = LibraryLoader(CDLL)

/usr/lib/python3.7/ctypes/init.py in init(self, name, mode, handle, use_errno, use_last_error) 362 363 if handle is None: --> 364 self._handle = _dlopen(self._name, mode) 365 else: 366 self._handle = handle

OSError: librebound.cpython-37m-x86_64-linux-gnu.so: cannot open shared object file: No such file or directory

I could share an example notebook if it helps, but the only other thing I've done is run pip install rebound reboundx. Is there any workaround, or is the library incompatible with Google Colab?

— Reply to this email directly, view it on GitHub https://github.com/dtamayo/reboundx/issues/87, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2ABFYQPTONCLY4UHOLDYDWDSOVVANCNFSM6AAAAAARGSU3ZU . You are receiving this because you are subscribed to this thread.Message ID: @.***>

rcanalese commented 1 year ago

Of course, here's the link: https://colab.research.google.com/drive/1cANDdAuDz0hHDd0o0V85a0VdGUEzJVAv?usp=sharing

dtamayo commented 1 year ago

Says I need access, sent a request

On Sun, Oct 16, 2022 at 7:22 PM rcanalese @.***> wrote:

Of course, here's the link: https://colab.research.google.com/drive/1cANDdAuDz0hHDd0o0V85a0VdGUEzJVAv?usp=sharing

— Reply to this email directly, view it on GitHub https://github.com/dtamayo/reboundx/issues/87#issuecomment-1280184138, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2ABF66BDMEK2JUDDOXTA3WDSZ5LANCNFSM6AAAAAARGSU3ZU . You are receiving this because you commented.Message ID: @.***>

rcanalese commented 1 year ago

Sorry, I think I fixed the access issue now. Either way, I may have found a tentative solution. I had been using pip install rebound reboundx at first, but when I switched to !pip install I had no trouble importing reboundx. I'm still testing to see if any other issues arise, but at least the importing issue seems to have been solved.

hannorein commented 1 year ago

I'm not sure what is going on but one issue could occur when trying to install both packages at once. I tend to have more luck first installing rebound, then reboundx. We're probably doing something wrong with the package requirements and shared libraries, but I'm not sure what...

dtamayo commented 1 year ago

I'm not totally sure what

pip install reboundx

is doing in colab when you don't include an exclamation point, but

!pip install reboundx

is definitely the right command to execute the command in the shell. I just ran it in a colab notebook (without installing rebound first) and it installed both no problem.

Closing for now, but feel free to reopen if there are further issues!