skip to Main Content

When I try to run my python projects, in some cases I get this error:

  File "/usr/local/bin/AAA/camera_service/camera_service_main.py", line 6, in <module>
    from views.hires_camera_handler_view import hires_camera_handler_blueprint
  File "/usr/local/bin/AAA/camera_service/views/hires_camera_handler_view.py", line 7, in <module>
    from hires_camera_handler.hires_camera_handler import HiResCameraHandler
  File "/usr/local/bin/AAA/camera_service/hires_camera_handler/hires_camera_handler.py", line 3, in <module>
    from ids_peak import ids_peak
  File "/home/izx/anaconda3/envs/py38/lib/python3.8/site-packages/ids_peak/ids_peak.py", line 18, in <module>
    from . import _ids_peak_python_interface
ImportError: libpython3.8.so.1.0: cannot open shared object file: No such file or directory  

The object file exists in ~/anaconda3/envs/py38/lib

I can make the code run in my terminal by adding
export LD_LIBRARY_PATH=~/anaconda3/envs/py38/lib

However, there seems to be a deeper problem here, because more of my projects behave differently then on other ubuntu installs. I could of course reinstall ubuntu. But I would like to understand what I did wrong here.

Also, the solution above doesn’t solve the issue. I can still not run my tests in PyCharm and that would be really beneficial. Probably I can somehow set this value in my pycharm run, however, setting the path variable didn’t work and I wouldn’t know how to do it.

I have tried various solutions. installing libpython3.8 (its already installed), installing libpython3.8-dev (its not available on ubuntu 22.04 jammy). I’ve also added the value to bashrc but as expected that doesn’t solve it for PyCharm.

Can anyone explain to me exactly what the problem is here? Why is my conda environment not able to find its own lib folder? Why does adding the path to LD_LIBRARY_PATH work? It doesnt make sense to me that my conda environment needs the shared files when it got its own. What is the default location for conda to look for the shared files? How can this happen all of sudden when I have installed anaconda many times on many systems? I know these are a lot of questions, but I hope they can give me the answers I need to understand this problem instead of follow other SO-posts blindly.

Thank you

2

Answers


  1. It is always worth reading the docs from anaconda:
    https://docs.conda.io/projects/conda-build/en/latest/resources/use-shared-libraries.html#shared-libraries-in-macos-and-linux

    You have to tell python where to find the additional modules by setting the PYTHONPATH in ~/.bashrc; Make sure to reload / restart the terminal or your IDE after updating ~/.bashrc

    e.g.

    export PYTHONPATH="${PYTHONPATH}:/Users/<myuser>/project_root_folder_path"
    

    see Permanently add a directory to PYTHONPATH?

    Login or Signup to reply.
  2. If your system is Ubuntu, you can find this file as I do and copy it to /lib/ or /lib64/

    1. find / -name libpython3.8.so.1.0

    screenshot

    1. sudo cp /home/zhou/anaconda3/envs/paddlep/lib/libpython3.8.so.1.0 /usr/lib/

    or

    1. sudo cp /home/zhou/anaconda3/envs/paddlep/lib/libpython3.8.so.1.0 /usr/lib64/
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search