8

enter image description hereenter image description hereI was trying to use tensorflow in Pycharm IDE.

It seems that in Pycharm, it is one-click to install a package. It was very easy with bumpy. Now error occurs when I was trying to install tensorflow. Tensorflow was installed through terminal on Mac, as screenshot shows, using the command

sudo pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0-py2-none-any.whl (Refer to https://www.tensorflow.org/versions/r0.8/get_started/os_setup.html#pip-installation) Any suggestions ? Thanks.

enter image description here

Ancalagon BerenLuthien
  • 1,154
  • 6
  • 20
  • 29

5 Answers5

16

If you install tensorflow with the virtualenv option and want to use it from Pycharm for a project, you need to set up a corresponding virtualenv interpreter. There are a few solutions on the forum, for example How to get VirtualEnv TensorFlow to work in PyCharm?, however, that one didn't work for me with a "python packaging tools not found pycharm" error.

This is a working solution for me, first create a virtualenv from Pycharm and then install tensorflow there:

  1. In Pycharm, Preferences -> Project interpreter -> Create VirtualEnv -> give the virtualenv a name and location of your choice, and select "inherit global site-packages" option -> OK. create virtualenv
  2. In command line, install tensorflow in the virtualenv location you created in Step 1. For the above case, the location is ~/tensorflow_pycharm, therefore, run command virtualenv --system-site-packages ~/tensorflow_pycharm

  3. In Pycharm, select the created project interpreter, and select the tensorflow package, double click to install the package.

  4. If Step 3 is successful, set run configuration, and try run a sample program. run config sample program

Community
  • 1
  • 1
Shunan Zhang
  • 311
  • 3
  • 3
  • This answer is perfect. Thank you! – 416E64726577 Mar 18 '17 at 20:58
  • I installed tensorflow via "https://www.tensorflow.org/install/install_mac", then use the step 1 to add a new project interpreter, whose interpreter path is targetDirectory(i.e. /xxx/tensorflow/bin/python), then it works for me. – Woody Sun Dec 03 '17 at 10:05
6

Update - Nov. 1, 2017:

Tried successfully with Latest Jetbrain PyCharm Community Edition (2017.2.4) and Python 2.7.14, with Installing with virtualenv of https://www.tensorflow.org/install/install_mac.

Install tensorflow with virtualenv

Install tensorflow with virtualenv

virtualenv folder

Add Local to Project Interpreter.

Select Project Interpreter

Pycharm configuration

Run the script

enter image description here

enter image description here

Generate graph

Run tensorboard --logdir=/tmp/tensorflow_logs in Terminal of PyCharm

enter image description here

See graph in browser

Paul Lan
  • 665
  • 2
  • 9
  • 12
3

Go Preferences and search for the interpreter. You may see several interpreters. Select any interpreter which has the tensorflow package installed.

Check out the installed packages and double check the versions of tensorflow as shown in this picture.

enter image description here

Sung Kim
  • 8,417
  • 9
  • 34
  • 42
  • As my screenshot shows, there is no tensorflow version 0.8.0 in my Pycharm. There is a "0.1.0 version UNKNOWN", which I trust is a fake. – Ancalagon BerenLuthien May 03 '16 at 17:30
  • 1
    OK. Now I uninstalled Pycharm and re-installed the latest version of Pycharm, and Yes the tensorflow is there , version 0.8.0. However, still more error messages. I've relocated this problem into another thread named "Tensorflow import error on Pycharm (Mac)". Thanks a lot though. Appreciate. – Ancalagon BerenLuthien May 03 '16 at 18:27
2

To summarize (on Mac) :

Step 1, get latest Python (2.7.11 today) on Pycharm: Pycharm, can not find Python version 2.7.11

Step 2, follow "Pip Installation" of https://www.tensorflow.org/versions/r0.8/get_started/os_setup.html#download-and-setup

Step 3, Pycharm-- preference -- project interpreter, install the latest versions of numpy, protobuf, six. Tensorflow import error on Pycharm (Mac) Note, maybe have to click the "specify version" when installing.

Step 4, Pycharm-- preference -- project interpreter, install the latest version of tensorflow (v 0.8.0 today). Note, if not find v0.8.0, then maybe have to manually click "Manage Repositories" and then add the link of Step 2 (https://storage.googleapis.com/tensorflow/mac/tensorflow-0.8.0-py2-none-any.whl)

These steps worked well on both Mac computers of mine. Thanks for all helps during the procedure from contributors.

Community
  • 1
  • 1
Ancalagon BerenLuthien
  • 1,154
  • 6
  • 20
  • 29
  • Man!!!! You are a super hero.... i was trying to install tensorflow in pycharm for the past one week and your answer helped me to install it. I wish I could have seen it the first day itself... thank u so much –  Mar 21 '17 at 04:57
0

Steps I followed 1. Use the virtualenv option in tensor flow's official guide for installation and follow the steps exactly to install and set up tensor flow. Although we've already created a virtual environment here, I created a separate one for Pycharm projects.

This is how you do it. 1. Create a new project. Go to Preferences. Go to interpreter and create a new virtualEnv. Give it a name and check on the box "inherit global site-packages". Press "OK". creating a virtualenv

  1. Below are a list of Packages. Here's where I couldn't find tensor flow initially. If this is the case, there's a + symbol on the bottom left. Click on it and manually search for "tensorflow". Click on "install package" on the bottom left. installing tensorflow package After the installation is done press OK.Close this screen. Tensorflow will now appear on the installed packages list. Press ok. Now test your installation with a program.

    import tensorflow as tf
    hello = tf.constant("hello TF")
    sess = tf.Session()
    print(sess.run(hello))
    

Hope this helps.