tensorflow import issue for python 3.7 - tensorflow

After installing tensorflow for python 3.7, I tried to import it but it gave me a syntax error.
the command used for installation :
sudo -H pip3 install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.10.0-py3-none-any.whl
I don't think tensorflow has supported python3.7 yet. Is there a way to fix it?
enter image description here

You can solve this by simply changing the name of all these (Ctrl + R and Replace All) from async to for example async1 as also this post suggests.
But even after fixing it you will probably encounter other problems with Tensorflow and Python 3.7.0 . For more details see my answer here: Does TensorFlow 1.9 support Python 3.7

tensorflow import for python 3.7
for Anaconda 2019.03 with Python 3.7 version
for CPU
create command:
conda create -n tensorflow_env tensorflow
activate command:
conda activate tensorflow_env
Import command:
(tensorflow_env) C:\WINDOWS\system32>python
import tensorflow as tf
print(tf.version)
for GPU
create command:
conda create -n tensorflow_gpuenv tensorflow-gpu
activate command:
conda activate tensorflow_gpuenv
Import command:
(tensorflow_gpuenv) C:\WINDOWS\system32>python
import tensorflow as tf
print(tf.version)

Related

Error when installing TensorFlow through pip

I'm following the instructions from https://www.tensorflow.org/install/pip#python-version-support to install tensorflow. I've used tensorflow before but for some reason, it has just stopped working. I'm using VS Code.
First, I check that pip and python are compatible:
python3 --version
python3 -m pip --version
I have Python 3.10.8, with pip 22.3.1 so it should be compatible. Then, I create a conda environment and activate it:
conda create --name tf python=3.9
conda activate tf
However, now when I try
pip install tensorflow
I get the error
ERROR: Could not find a version that satisfies the requirement tensorflow (from versions: none)
ERROR: No matching distribution found for tensorflow
How can I fix this? I also tried things in the past like installing tensorflow through Conda, but I get errors when importing tensorflow there.
Could you please try again by opening anaconda cmd propmt and run below code:
conda create --name tf_new python=3.10
conda activate tf_new
then install tensorflow using:
pip install tensorflow
Now open the VS code by selecting the same created VirEnv tf_new from Anaconda navigator.
In VScode, Open a new jupyter notebook file and run the below code by selecting the tf_new (Conda VirEnv) in kernel(from top right) .
import tensorflow as tf
tf.__version__
Output:
'2.11.0'

Downgrading TensorFlow from 1.15 to 1.14 not working

I have a colab notebook which was running tf1.15.0. I need to downgrade it to 1.14.0. In a cell, it run the following:
!pip uninstall tensorflow==1.15.0
!pip install tensorflow==1.14.0
import tensorflow as tf
print(tf.__version__)
However, it outputs:
> 1.15.0
What am I doing wrong please?
CS
IF you have import tensorflow cell before uninstall, you may need to restart notebook to make it effective.
IF you have not, make sure you are running the correct pip in the same python environment as the notebook, such as:
import sys
!{sys.executable} -m pip install xx
Do you have TensorFlow-GPU installed in the system? Because this is the same issue I was facing earlier, so try downgrading TensorFlow-GPU.
pip install tensorflow-gpu==1.14
or any other version of tensorflow-gpu.

How to address Error when I import tensorflow as tf

I install the tensorflow python3.6 cpu version but when I import tensorflow as tf, it shows import: not authorized `tf' # error/constitute.c/WriteImage/1028. Is there anyone can help me? My system is ubuntu 16.04
Try to create a conda environment with python 3.6(you can change the python version to suit your needs) using following commands and try installing tensorflow
conda create -n <env-name> python=3.6
source activate <env-name>
pip install tensorflow
It will resolve your issue
I got a similar issue.
Did you mention which interpreter to use?
You can either add the shebang #!/usr/bin/env python3 at the beginning of your script or run the script as python3 script.py. This fixed the issue for me.

Python cannot find Tensorflow module

With Python3.5, I try to use the 'tensorflow' module:
import tensorflow as tf
But.. it says No mudule named tensorflow
I just tried to download the module with pip3:
pip3 install --upgrade tensorflow-gpu
(I have all the requirements to run tensorflow with GPU support as described at tensorflow.org)
I've seen a similar question here ImportError: No module named tensorflow , here's a sum up of what's inside:
Make sure installation is correct via:
pip3 show tensorflow
You can optionally re-install it again using: pip install tensorflow==1.2.0 --ignore-installed
Make sure you're running the python code with Python 3.x, verify using: python --version
Make sure you install TF and run the script through the same user, avoid installing TF using sudo pip install... and running the code with python script.py

Cant import keras

I ran the following on my Anaconda command prompt for python 3.6:
pip install keras
Next, typing the following on Spyder:
import keras
The above gives me an error:
No module named 'tensorflow'
Tring to do pip install tensorflow on the Anaconda command prompt gives me the follwing error:
No matching distribution found for tensorflow
To install a module into anaconda, use
$ conda install tensorflow
The command that you ran
$ pip install tensorflow
will not install it inside the anaconda virtualenv for python.
If you try
$ python
>>> import keras
This will work after pip install tensorflow. However, use conda package manager to install modules to anaconda.