简体   繁体   中英

Error using Tensorflow virtualenv in Pycharm (Ubuntu 16)

I've installed Tensorflow within a virtual environment on my machine. It works from the command line but when I try to run it from Pycharm it gives the following error: Pycharm Console Output

The project interpreter is set to virtualenv at ~/tensorflow and for the interpreter paths the following ones are set:

  • /home/user/tensorflow/lib/python3.5
  • /home/user/tensorflow/lib/python3.5/plat-x86_64-linux-gpu
  • /home/user/tensorflow/lib/python3.5/lib-dynload
  • /usr/lib/python3.5
  • /usr/lib/python3.5/plat-x86_64-linux-gnu
  • /home/user/tensorflow/lib/python3.5/site-packages
  • /usr/lib/python3.5/site-packages
  • /usr/local/lib/python3.5/dist-packages
  • /usr/lib/python3/dist-packages

The code (from a tutorial) I've tried to run is the following:

    import tensorflow as tf

    x = tf.constant(35, name='x')
    y = tf.Variable(x + 5, name='y')

    model = tf.global_variables_initializer()

    with tf.Session() as session:
    session.run(model)
    print(session.run(y))

So what could this error be related to?

Ok, so it works if you call Pycharm from the terminal. I guess that the terminal context is given to pycharm the moment you load it from the command line. (Pycharm is executed from the command line by executing the pycharm.sh script. If you don't know how where it is then type 'locate pycharm.sh')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM