PyCharm cannot find library
Solution 1
I came across this problem just recently using a remote debugger, however I believe it's still the same solution. I just added the following to the Environment Variables section in the Run/Debug Configuration options found in Run > Edit Configurations... dialog: LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
Solution 2
The path to your cuda library seems strange to me. I would expect it to be /usr/local/cuda-7.0/lib64
or /usr/local/cuda-7.0/lib
.
Did you follow all of the cuda installation procedure?
If you type env
on the command line, do you see a path to cuda in your LD_LIBRARY_PATH
?
Update from comments below:
The issue is that PyCharm was invoked from the desktop, and wasn't getting the right environment variables. Solution is to either:
- invoke from the command line,
- create a script to set environment and then invoke, and make a link to that script on the desktop,
- or set environment variables on the desktop item
Solution 3
While some of these answers are correct, and could work, I haven't seen what the OP specifically asked for, and that is where to set environments for the python console. This can be accomplished inside pycharm at:
File > Settings > Build,Execution,Deployment > Console > Python Console
In the options there, you'll find a place to define Environment Variables. Set LD_LIBRARY_PATH there.
Solution 4
Edit your pycharm.desktop
, specify the environment variable in exec, like below:
[Desktop Entry]
Version=1.0
Type=Application
Name=Pycharm
Exec=env LD_LIBRARY_PATH=:/usr/local/cuda/lib64:/usr/local/cuda/lib64 /home/cwh/software/pycharm-2016.1.4/bin/pycharm.sh
Icon=/home/cwh/software/pycharm-2016.1.4/bin/pycharm.png
Name[zh_CN]=Pycharm
so pycharm
will find cuda
Solution 5
Have you selected the right python interpreter in your project's settings? See here.
I had a similar issue and changing the interpreter solved it without having to create a new icon.
Karnivaurus
Updated on February 26, 2020Comments
-
Karnivaurus about 4 years
I am using PyCharm 5 to run a Python 2.7 (Anaconda) script in Ubuntu. My script imports a module with
import tensorflow
, but this causes the errorImportError: libcudart.so.7.0: cannot open shared object file: No such file or directory
. So, it seems that the librarylibcudart.so.7.0
is needed by this module, but it cannot be found.Now, I have seen that this library is on my machine in
/usr/local/cuda-7.0/targets/x86_64-linux/lib
. So, in PyCharm, I went toSettings->Project Interpreters->Interpreter Paths
. This had a list of paths, such as/home/karnivaurus/Libraries/Anaconda/python2.7
. I then added to this list, the path mentioned above which contains the required library.However, this did not fix the problem. I still get an error telling me that
libcudart.so.7.0
cannot be found. If I run my script from the shell though (python myfile.py
), then it runs fine.How can I tell PyCharm where to find this library?
I have noticed that if I have
print sys.path
in my script, the paths it prints out are entirely different to those inSettings->Project Interpreters->Interpreter Paths
... should they be the same?