Import Tesator Library Release

The following program works well in anaconda from the command line interface (I use Mac OS), but it has errors that you cannot import / find the tenorflow module from PyCharm (using Python 2.7). I already installed the Python interpreter as anaconda in PyCharm, still got this error. If anyone has any ideas, this will be great.

Here is a simple program that I use, as well as a screenshot of PyCharm.

import tensorflow as tf hello = tf.constant('Hello, TensorFlow!') sess = tf.Session() print(sess.run(hello)) a = tf.constant(10) b = tf.constant(32) print(sess.run(a + b)) 

enter image description here enter image description here

Update 1 , how to set up a Python interpreter in PyCharm,

enter image description here

Update 2 , post-output for python -c 'import sys; print(sys.path)' python -c 'import sys; print(sys.path)'

['', '/Users/admin/miniconda2/lib/python2.7/site-packages/six-1.10.0-py2.7.egg', '/ Users / admin / miniconda2 / lib / python27. zip ',' / Users / admin / miniconda2 / lib / python2.7 ',' / Users / admin / miniconda2 / lib / python2.7 / plat-darwin ',' / Users / admin / miniconda2 / lib / python2.7 / plat-mac ',' / Users / admin / miniconda2 / lib / python2.7 / plat-mac / lib-scriptpackages ',' / Users / admin / miniconda2 / lib / python2.7 / lib-tk ',' / Users / admin / miniconda2 / lib / python2.7 / lib-old ',' / Users / admin / miniconda2 / lib / python2.7 / lib-dynload ',' / Users / admin / miniconda2 / lib / python2.7 / site packages]

Update 3 ,

Mail File menu and PyCharm version, enter image description here

enter image description here

Update 4 , Settings => Setting up the project interpreter,

enter image description here

Update 5 , a screenshot of the package list,

enter image description here

Update 6 , using miniconda other than conda does not cause problems, post-screen shots,

enter image description here

enter image description here

+4
python pycharm tensorflow anaconda
source share
2 answers

In the Preferences => Project Interpreter settings, is there a tensor flow among packages?

Apparently not (from screenshots).

Are there any other panda conda installations when using the dropdown list for the project interpreter? If there is, try and see what happens. The tensorflow package tensorflow definitely in another conda installation.

From this post on SO:

conda is a package manager. Anaconda is a collection of about a hundred packages, including conda, numpy, scipy, ipython notebook, etc.

You installed Miniconda, which is a smaller alternative to Anaconda, it’s just conda and its dependencies (unlike Anaconda, which is conda and many other packages, such as numpy, scipy, ipython laptop, etc.). When you have Miniconda, you can easily install Anaconda in it with conda install anaconda.

So, conda is a package manager, Anaconda is a collection of packages, and mini conda (my accent) is an easy alternative to Anaconda.

You must create virtualenv to avoid such problems in the future.

+7
source share

You need to follow these steps:

  • Go to settings (ctrl + alt + s or the menu "File" β†’ "Settings" or "alt + f + t")
  • Under Prject: go to Project Interpreter
  • Select the interpreter you want to use
  • Press the gearshift button (top right - next to translator selection)
  • Click Details
  • Press the right interpreter for your project, and then on the fifth button on the right:
  • enter image description here

  • Click the + button and add the path to the directory containing the initialization file for this library.

Hope this answer helped you

+2
source share

All Articles