tensorflow / agents

TF-Agents: A reliable, scalable and easy to use TensorFlow library for Contextual Bandits and Reinforcement Learning.
Apache License 2.0
2.79k stars 722 forks source link

Problem with reverb inside conda environment #724

Open a-berg opened 2 years ago

a-berg commented 2 years ago

Steps to reproduce:

conda env create -n tf-agents
conda activate tf-agents
pip install tf-agents[reverb]
python
>>>import reverb

The error I get is:

ImportError: libpython3.10.so.1.0: cannot open shared object file: No such file or directory

It doesn't matter whether I use python 3.8, 3.9 or 3.10 inside the environment. Does reverb expect libpython be installed in the system instead of the conda env and doesn't find it? (IIRC, system python is 2.7.18 / python3 == 3.8.10, defaults to 2.7)

makisgrammenos commented 2 years ago

If you are using ubuntu or another debian based OS try:

sudo apt-get install libpython3.10

jammy-li commented 2 years ago

I have the same problem.

When I try sudo apt-get install libpython3.10, the output is:

WechatIMG55

Step to reproduce:

conda create -n tf-agents python
conda activate tf-agents
pip install tf-agents[reverb]
python
>>>import reverb

The error I get is:

File "xxx/anaconda3/envs/tf-agents/lib/python3.10/site-packages/reverb/pybind.py", line 4, in <module>
    from .libpybind import *
ImportError: libpython3.10.so.1.0: cannot open shared object file: No such file or directory

But I can find the file ( libpython3.10.so.1.0 ) in ···/anaconda3/envs/tf-agents/lib.

WX20220410-223215@2x

Can you help me solve this problem?

Thank you in advance.

tgohh commented 2 years ago

I have been having the same problem.

It looks like it is linked to the LD_LIBRARY_PATH environmental variable.

Assuming you are using miniforge3, running this makes the error go away:

export LD_LIBRARY_PATH=~/miniforge3/envs/your_env_name/lib:$LD_LIBRARY_PATH

(libpython3.so is in the lib folder of your environment directory)

Also, when I did that, I found out that pip created an inconsistent environment when it installed reverb using this command from tensorflow

pip install tf-agents[reverb]

With that command, it only works by ensuring numpy>=1.25, with reverb==0.7.0; or lowering the version number of reverb).

Right now, my environment with working version numbers are:

Fixing this will probably mean modifying the activate command to include the */lib directory, since there are a few packages that look like they are depending on it.

jammy-li commented 2 years ago

I have solved this problem successfully.

If you can find libpython3.10.so.1.0 in /path-to-conda/envs/your-env-name/lib and your IEDA is 'PyCharm', you can try the following methods:

  1. select the file contained import reverb.
  2. Run->Edit configurations.
  3. add LD_LIBRARY_PATH=/home/zmli/anaconda3/envs/tf-agents-nightly/lib in environment variables.
  4. run the file.