dtamayo / reboundx

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

python 3.6 librebound.cpython-36m-x86_64-linux-gnu.so import error #26

Closed Yeqzids closed 6 years ago

Yeqzids commented 6 years ago

import reboundx gives me OSError: librebound.cpython-36m-x86_64-linux-gnu.so: cannot open shared object file: No such file or directory unless I do it under the python3.6/site-packages directory. Anyone has this error? I almost suspect I missed something obvious...

python 3.6.5 rebound 3.5.12, reboundx 2.18.1 installed via pip

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
<ipython-input-58-227e1b4154d8> in <module>()
      7  
      8 
----> 9 import reboundx
     10 rebx = reboundx.Extras(sim)
     11 rf = rebx.add("radiation_forces")

~/anaconda3/lib/python3.6/site-packages/reboundx/__init__.py in <module>()
     11 pymodulespath = os.path.dirname(__file__)
     12 from ctypes import *
---> 13 clibreboundx = cdll.LoadLibrary(pymodulespath + '/../libreboundx' + suffix)
     14 
     15 # Version

~/anaconda3/lib/python3.6/ctypes/__init__.py in LoadLibrary(self, name)
    424 
    425     def LoadLibrary(self, name):
--> 426         return self._dlltype(name)
    427 
    428 cdll = LibraryLoader(CDLL)

~/anaconda3/lib/python3.6/ctypes/__init__.py in __init__(self, name, mode, handle, use_errno, use_last_error)
    346 
    347         if handle is None:
--> 348             self._handle = _dlopen(self._name, mode)
    349         else:
    350             self._handle = handle

OSError: librebound.cpython-36m-x86_64-linux-gnu.so: cannot open shared object file: No such file or directory
dtamayo commented 6 years ago

Are you using a virtual environment (or conda environment)? If not I definitely recommend doing that. If you are not familiar with it, there are instructions at the top of here: http://rebound.readthedocs.io/en/latest/python_quickstart.html

Yeqzids commented 6 years ago

I am using conda, but my reboundx is installed via pip because there is no conda package for Linux. I will try virtualenv to see if it helps. Thanks!

dtamayo commented 6 years ago

you can pip install into a conda environment (that's what I do). Let me know if it resolves the issue

Yeqzids commented 6 years ago

Yes, this solved my problem. Thanks!

Yeqzids commented 6 years ago

In case anyone runs into similar problems like me... upgrade rebound (not reboundx) to 3.5.13 appears to solve the problem.

pavlikva commented 7 months ago

I had the same error with Python_3.10, Rebound_4.3.2 and Reboundx_4.1.0, but it was solved by putting this line in my .bashrc file export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$HOME/.local/lib/python3.10/site-packages"

GumballWatterso commented 6 months ago

@pavlikva where do I put this in my .bashrc file in order to resolve this error, I am having the exact same issue as you are right now with Python_3.10, Rebound_4.3.2 and Reboundx_4.1.0.

pavlikva commented 6 months ago

Anywhere. I put it at the end. Then reload bash.

GumballWatterso commented 6 months ago

@pavlikva ,it still did not work, I put it at the end of the .bashrc file, and then reload it using the command source ~/.bashrc. Did I do something wrong?

kgozdziewski commented 6 months ago

It works, after adding the PATH variable.

Does echo $SHELL gives you /bin/bash? If your shell is different, then the path variable must be consistent with the shell syntax.