How to install tensorflow in win 10 - tensorflow

The tensorflow is installed by using "conda install tensorflow". by importing tensorflow with "import tensorflow" in spyder in same environment which tensorflow was installed, it give an error "ModuleNotFoundError: No module named 'tensorflow'".

For every one who is faced with this problem i suggest to check if they have already installed spyder in desired environment with "conda install spyder". I installed it and the problem fixed

Related

ModuleNotFoundError: No module named 'tensorflow' error in vscode terminal while running fine in wsl

I installed tensorflow using conda in wsl, and now I'm using it through Jupyter notebook and it's working fine. I also write codes in vscode and then run it through wsl using python3 filename.py and it works fine too.
the problem is when I try to run the code using the 'running' option of vscode and then I get the error ModuleNotFoundError: No module named 'tensorflow' in terminal.
I checked my environments and I only have 'base' environment so the packages should be installed there and I also tried 'conda ...' in vscode terminal and it didn't recognize conda either.
what can be the problem with my vscode?
also I have to say that numpy and matplotlib packages are running fine using vscode itself but tensorflow and some other modules are not identified
You need to create a new virtual environment in anaconda to install Tensorflow and can access the Visual Studio code from the same virtual environment.
Open anaconda prompt and type below code to create virtual environment
conda create -n tf tensorflow
conda activate tf
install TensorFlow in that "tf" virtual environment
pip install tensorflow
launch VS code by selecting the same "tf" virtual environment in anaconda navigator.
Now, type the below code to check if TensorFlow installed successfully in VS code.
import tensorflow as tf
print(tf.__version__)
Likewise, you can install other required packages in the same virtual environment.
pip install <package-name>

Spyder can't load tensorflow in conda environment although python can

I created a conda environment including Spyder and tensorflow in the dependencies and all installs went without errors.
When I activate the environment and launch python, I can import tensorflow and run code without any issues.
However when launching spyder from within the environment (Spyder shows on the bottom of the GUI that is part of that conda environment), and load tensorflow, it throws an error:
ModuleNotFoundError: No module named 'tensorflow_core.estimator'
and from then the Console gets stuck repeating the same error.
Why does spyder have issues importing a module that python in the same environment can import? How can I fix this?
I have tried re-installing spyder in the conda environment but the same issue prevails.
Try to uninstall tensorflow-estimator pip uninstall tensorflow-estimator and uninstall Tensorflow.
#After fresh installing tensorflow
pip install tensorflow
#Install tensorflow_estimator
pip install -U tensorflow_estimator
Try this workaround as well.

Can't install tensorflow on python 3.9

When I try to install tensorflow on python 3.9 I get following error:
ERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none)
ERROR: No matching distribution found for tensorflow
Is not there any tensorflow for 3.9?
What do you guys recommend?
Can I install other version of python beside the existing version?
Right now tensorflow does not have a build for python3.9
The latest one is for python3.8
You can check the build files at PyPI
https://pypi.org/project/tensorflow/#files
yes, you can install another version of python.
The original poster did not mention what type of computer or operating system he was using while attempting to install TensorFlow alongside Python 3.9. The error could be linked to working on a 64-bit Mac with the M1 chip (I recently experienced the same error described above while working on a Mac M1 in a Miniconda environment with Python 3.9.13). I solved the error by running
python3 -m pip install tensorflow-macos
from Terminal (in the Miniconda environment). TensorFlow installed normally alongside Python 3.9.13.
I do recommend installing Miniconda (or Anaconda as others have suggested), because it will allow you to easily create development environments with whatever version of Python modules or dependencies you require at the moment. See https://docs.conda.io/en/latest/miniconda.html. The larger Anaconda comes with a user-friendly 'Navigator' GUI which enables you to choose which environment is used to open a Jupyter notebook or other development environment, several of which come with Anaconda. See https://docs.anaconda.com/anaconda/install/
This is terrible with newer versions of Python that are not compatible with the machine learning module package.
So my approach is to keep the existing version 3.9 and the computer is using Anaconda to install a virtual environment with 3.7. When using vscode or pycharm, just remember to set it to that 3.7 Python environment.

Still getting Tensorflow 2.0.0 behavior after installing Tensorflow 1.15.0

I installed Tensorflow 1.15.0 on one of the conda environment named tensorflow1 but still print(tf.__version__) is printing 2.0.0.
Also, tf.InterativeSession() is not present in tensorflow 2.0. FYI, I activated the conda environment and I am working in PyCharm for my project.
Please help.
Check where your pip is pointing to.
In conda environment pip should point on
/userName/.conda/envs/env_name(tensorflow1 )/bin/pip this path is local to your environment.
and inside environment don't use --user while installing packages.

Anaconda prompt crashes as soon as I activate tensorflow env

I have just installed Anaconda 3.7 in Windows 10. Then I have created a new env for
tensorflow and installed it there. It got installed without any problem. Then I
used the command
conda install -c conda-forge keras
to install Keras. While Keras installation was running, Anaconda Prompt crashed suddenly. I restarted it and I tried to activate my tensorflow env; but as soon as I try to activate it, Anaconda Prompt crashes!! Please take a look at my screenshot. How can I fix this? Thank you very much for your support.
Ferari
Anaconda Prompt Crashes
The problem could be due to the version of tensorflow - tensorboard mismatch. When you give the command conda install -c conda-forge keras for installing keras, the tensorflow and tensorboard versions gets changed.
I tried the following steps and it worked fine for me.
conda create -n tf python=3.6
activate tf
conda install keras
Installing keras will automatically install tensorflow.
I just had an issue with the same symptom. Instead of printing the error message, the activation of the conda environment exited the console application.
The scripts that run on activation can be found in ./etc/conda/activate.d inside the environment. The path to the environments can be found using conda env list. Check these scripts for any 'exit' commands, commenting them out if necessary. This should let you at least see the error message.
In my case the issue was caused by packages requiring MSVC compiler, and Visual Studio studio was not installed.
I was also facing the same error and i have resolved it by re creating the conda environment. It is happening due to version mismatch between couple of packages. Just delete the conda environment and re-create the environment but this time do not add tensorflow GPU package instead just add keras-gpu, it will take care everything.
I did the following things:
deleted the same env
created the same environment using
conda create -n myEnv python==3.6
install keras gpu
conda install -c conda-forge keras-gpu
now it will install necessary packages and then you can activate the environment and use it
I encountered the same problem. Solved by creating a new env and using
conda install -c hesi_m keras
This will install the latest versions of Keras and Tensorflow.
Turns out you will most likely get an outdated version of keras if you installed it with conda install -c conda-forge keras.
Same problem here..
I just have installed tensorflow-gpu in tf-gpu environment using
conda install tensorflow-gpu
It has successfully installed and works perfectly. But after installation whenever I am going to use environment by this command
activate tf-gpu
it shows the followingenter image description here output and close the command prompt soon. I am using anaconda for python 3.6.
when you open Anaconda command prompt just press ctrl+c and press Y to avoid the crash for now and then start again with the task of setting the environment for tensorflow...
this worked for me..