PyCharm cannot find library

后端 未结 6 1351
我在风中等你
我在风中等你 2020-12-18 19:43

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 ImportE

相关标签:
6条回答
  • 2020-12-18 19:47

    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
    0 讨论(0)
  • 2020-12-18 19:53

    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

    0 讨论(0)
  • 2020-12-18 20:00

    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.

    0 讨论(0)
  • 2020-12-18 20:02

    The following works for me on Community edition 2019.3

    To set globally for a project:

    • Open File/Settings/Project/Project Interpreter
    • click on the cog icon next to the interpreter
    • choose show all
    • click on the little folder with tree icon bottom right
    • add the path to "Interpreter Paths"
    0 讨论(0)
  • 2020-12-18 20:04

    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.

    0 讨论(0)
  • 2020-12-18 20:05

    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

    0 讨论(0)
提交回复
热议问题