Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding library directory to PyCharm

On Ubuntu 15.10, I am running PyCharm Community Edition version 2016.1. I have a Python file which calls import tensorflow, a module which depends on the CUDA library libcudart.so.7.5. When I run this file, I get the following error message:

ImportError: libcudart.so.7.5: cannot open shared object file: No such file or directory

Now, the file libcudart.so.7.5 is located on my machine at /usr/local/cuda-7.5/lib64. And in Pycharm, I have added this path to File->Settings->Project Interpreter->Interpreter Paths. So, I am puzzled as to why PyCharm cannot find libcudart.so.7.5 given that the directory containing it is listed as an interpreter path.

Furthermore, if I run this file from the command line, it runs fine without the above error. In my .bashrc file, I have the line:

export LD_LIBRARY_PATH=/usr/local/cuda-7.5/lib64:$LD_LIBRARY_PATH

So this seems to be allowing the library file to be found. But how can I get PyCharm to find the library? My understanding was that adding the path to the interpreter paths was the solution, but it seems that this may not be correct...

Thanks!

like image 368
Karnivaurus Avatar asked Mar 29 '16 00:03

Karnivaurus


Video Answer


1 Answers

PyCharm execution environment is independent of your .bashrc.

Assuming it is the environment variable set by .bashrc which is making it work in your shell, you should try to set that environment variable in the PyCharm run configurations.

In Run -> Edit Configurations..., add the environment variable there:

enter image description here

like image 179
wim Avatar answered Sep 26 '22 01:09

wim