Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PyCharm cannot find library

Tags:

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 error ImportError: libcudart.so.7.0: cannot open shared object file: No such file or directory. So, it seems that the library libcudart.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 to Settings->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 in Settings->Project Interpreters->Interpreter Paths... should they be the same?

like image 623
Karnivaurus Avatar asked Nov 19 '15 19:11

Karnivaurus


People also ask

How do I install libraries in PyCharm?

Expand the list of the available versions in the upper-right corner of the tool window. Select the required version or keep it the latest. Click the Install button next to the version list. Once PyCharm notifies you about successful installation, you should see the package in the list of the installed packages.

Why import is not working in PyCharm?

Try installing/importing a package from the system terminal (outside of PyCharm) using the same interpreter/environment. In case you are using a virtualenv/conda environment as your Project Interpreter in PyCharm, it is enough to activate that environment in the system terminal and then do the test.

Can you pip install in PyCharm?

Pycharm supports installation, uninstallation, and up-gradation of Python packages. By default, Pycharm makes use of the pip package manager for the same.


1 Answers

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

like image 92
ktx Avatar answered Sep 22 '22 21:09

ktx