Article Directory
Preface
Because I want to use Anaconda's built-in compiler Spyder, I used Anaconda Prompt to reconfigure tensorflow. I encountered the same error as the cmd that came with Windows. I used the same method to solve the error and successfully tested the hello world program in Anaconda Prompt.
This article introduces how to use tensorflow in Spyder.
One, the problem
An error was reported when using Spyder to compile. This is due to the need to install Spyder in the tensorflow environment.
The test code is as follows:
import tensorflow as tf
hello = tf.constant("hello,tensorflow")
sess = tf.Session()
print(sess.run(hello))
The error screenshot is as follows
Two, the solution
Find Anaconda Navigator
and open it in the start menu bar , as shown in the figure. After
opening, select Environment
, then select the environment we created tensorflow
, select Not installed
, and enter directly in the search box spyder
, tick the small box in front, and click Apply
to install in the lower right corner , as shown in the figure:
After the installation is complete, you can Installed
view the installed spyder in, green √
means it has been installed, as shown in the figure:
back to the Home
interface, you can see the installed one Spyder
, click Launch
run, as shown in the figure:
run in spyder, the first time There will be a
lot of warnings in the operation, but ignore it. The output of the second run is normal, as shown in the figure: back to the start menu, you can also see that the Spyder in the tensorlfow environment is generated.
Note that to use tensorflow, you must open the tensorflow environment spyder, otherwise it will still report an error that the module cannot be found. Open the Spyder below the figure above, and the running result is as shown in the figure.
Similarly, using tensorflow in ipython can also use similar steps to install.
to sum up
After successful installation, tensorflow can be used in spyder.