I've tried installing tflearn through pip as follows
pip install tflearn
and now when I open python, the following happens:
>>> import tflearn
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "//anaconda/lib/python2.7/site-packages/tflearn/__init__.py", line 22, in <module>
from . import activations
File "//anaconda/lib/python2.7/site-packages/tflearn/activations.py", line 7, in <module>
from . import initializations
File "//anaconda/lib/python2.7/site-packages/tflearn/initializations.py", line 5, in <module>
from tensorflow.contrib.layers.python.layers.initializers import \
ImportError: cannot import name variance_scaling_initializer
Any ideas? I'm using an anaconda installation of python.
The variance_scaling_initializer() function was added on April 19th, which means that it wasn't included in version 0.8.0rc0, and you need to upgrade to a newer version of TensorFlow. If you upgrade to the 0.9.0rc0 version that was released this week, tflearn should work.
Last tflearn update had a compatibility issue with old TensorFlow versions (like mrry said, caused by 'variance_scaling_initializer()' that was only compatible with TensorFlow 0.9).
That error had already been fix, so you can just update TFLearn and it should works fine with any TensorFlow version over 0.7.
This is because your TensorFlow version is too low. Tflearn requires tensorflow‘s version >= 1.0, so you should reinstall tensorflow again, and reinstall step like this:
For python2.7:
sudo pip install tensorflow==1.0 #cpu version
sudo pip install tensorflow-gpu==1.0 # gpu version
For python3:
sudo pip3 install tensorflow==1.0 #cpu version
sudo pip3 install tensorflow-gpu==1.0 # gpu version
Related
I am having problems trying to run TensorFlow on my Windows 10 machine. Code runs fine on my MacOS machine.
Traceback (most recent call last):
File "c:\Users\Fynn\Documents\GitHub\AlpacaTradingBot\ai.py", line 15, in <module>
from keras.models import Sequential, load_model
File "C:\Users\Fynn\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\__init__.py", line 24, in <module>
from keras import models
File "C:\Users\Fynn\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\models\__init__.py", line 18, in <module>
from keras.engine.functional import Functional
File "C:\Users\Fynn\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\engine\functional.py", line 24, in <module>
from keras.dtensor import layout_map as layout_map_lib
File "C:\Users\Fynn\AppData\Local\Programs\Python\Python39\lib\site-packages\keras\dtensor\__init__.py", line 22, in <module>
from tensorflow.compat.v2.experimental import dtensor as dtensor_api # pylint: disable=g-import-not-at-top
ImportError: cannot import name 'dtensor' from 'tensorflow.compat.v2.experimental' (C:\Users\Fynn\AppData\Local\Programs\Python\Python39\lib\site-packages\tensorflow\_api\v2\compat\v2\experimental\__init__.py)
This can be caused by an incompatibility between your tensorflow and your keras versions. In particular I see this with tensorflow==2.6.0 and keras==2.9.0, though I would not be surprised if other versions can cause this as well.
Either update your tensorflow version by:
pip install tensorflow==2.8
or downgrade your keras version by:
pip install keras==2.6
Just run :
pip install --disable-pip-version-check --no-cache-dir tensorflow
Before you must delete tensorflow and keras folder at site-package.
Open admin command prompt use this codes
pip uninstall tensorflow
pip install tensorflow --ignore-installed
I tried many solutions to no avail, in the end this worked for me!
pip3 uninstall tensorflow absl-py astunparse flatbuffers gast google-pasta grpcio h5py keras keras-preprocessing libclang numpy opt-einsum protobuf setuptools six tensorboard tensorflow-io-gcs-filesystem termcolor tf-estimator-nightly typing-extensions wrapt
pip3 install --disable-pip-version-check --no-cache-dir tensorflow
Solutions tried:
pip install tensorflow
pip show tensorflow --ignore_installed
pip install tensorflow==2.0.0-rc0
conda install -c conda-forge tensorflow
conda install tensorflow
pip3 show tensorflow
pip show tensorflow
Note: you may need to restart the kernel to use updated packages.
WARNING: Package(s) not found: tensorflow
Tried restarting kernel.
Tried restarting laptop
Code trying to run:
from keras.models import load_model
Error:
runcell(0, 'C:/Users/chinm/untitled1.py')
Traceback (most recent call last):
File "C:\Users\chinm\anaconda3\lib\site-packages\keras_init_.py", line 3, in
from tensorflow.keras.layers.experimental.preprocessing import RandomRotation
ModuleNotFoundError: No module named 'tensorflow'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\chinm\untitled1.py", line 14, in
from keras.models import load_model
File "C:\Users\chinm\anaconda3\lib\site-packages\keras_init_.py", line 6, in
'Keras requires TensorFlow 2.2 or higher. '
ImportError: Keras requires TensorFlow 2.2 or higher. Install TensorFlow via pip install tensorflow
I can't see your code, but it appears your key error is Keras requires TensorFlow 2.2, while you installed pip install tensorflow==2.0.0-rc0. 2.0 < 2.2. Have you tried installing tensorflow 2.2 or up, or upgrading your existing version?
https://www.tensorflow.org/install/pip recommends:
pip install --upgrade tensorflow
with
python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"
to verify the installation.
then i type import tflearn i got the error below, i follow the guide here: https://www.youtube.com/watch?v=ViO56ASqeks
what can i use tflearn, or shall i use another code?
i got the error below.
import tflearn
File "/usr/local/lib/python3.5/dist-packages/tflearn/__init__.py", line 4, in <module>
from . import config
File "/usr/local/lib/python3.5/dist-packages/tflearn/config.py", line 5, in <module>
from .variables import variable
File "/usr/local/lib/python3.5/dist-packages/tflearn/variables.py", line 7, in <module>
from tensorflow.contrib.framework.python.ops import add_arg_scope as contrib_add_arg_scope
ImportError: No module named 'tensorflow.contrib.framework
can someone help me ?
20/08-2019: Edit 20.35
pip list:
tensorflow 2.0.0rc0
I had a similar problem and I solved it by:-
1) upgrading python to 3.6
2) pip uninstall tflearn
3) pip install git+https://github.com/tflearn/tflearn.git
4) As suggested in another solution tensorflow 2.0.0 does not support tflearn so I installed tensorflow==1.14.0
I found the solution here:-
Issue Link/
If you use an conda environment (and not only, but I advise you to use it), then the solution will be to use a lower version of tensorflow pip uninstall tensorflow pip install tensorflow==1.14.0.
And it is possible to use the script to fix all errors(i used it before downgrade tf):
tf_upgrade_v2 \
--intree my_project/ \
--outtree my_project_v2/ \
--reportfile report.txt
It works for me
You need to have tensorflow installed before you can use tflearn.
From the tflearn github page:
TensorFlow Installation
TFLearn requires Tensorflow (version 1.0+) to be installed.
To install tensorflow:
pip install tensorflow
The tutorial that you are watching uses tensorflow version 0.9 or something, current version is 2.0. The tutorial is 3 years old. You should watch updated video.
However, you can try.
pip install tensorflow==1.0
pip install tflearn
if you're using a virtual environment, make sure you have activated it.
You can use keras instead of tflearn.
tensorflow.contrib is being removed in version 2.0, you therefore need version <= 1.14 to operate tflearn (see here).
I am trying to import keras it gives me an error from tensorflow.python.ops import tensor_array_ops.
>>> import keras
Using TensorFlow backend.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/ss/anaconda2/envs/kerasenv/lib/python2.7/site-packages/keras/__init__.py", line 2, in <module>
from . import backend
File "/home/ss/anaconda2/envs/kerasenv/lib/python2.7/site-packages/keras/backend/__init__.py", line 67, in <module>
from .tensorflow_backend import *
File "/home/ss/anaconda2/envs/kerasenv/lib/python2.7/site-packages/keras/backend/tensorflow_backend.py", line 4, in <module>
from tensorflow.python.ops import tensor_array_ops
ImportError: cannot import name tensor_array_ops
I really appreciate if someone can help me to solve this error.
Thanks.
Try: sudo pip install tensorflow --upgrade
You may be using an older version of TensorFlow.
Did you install tensorflow at all?
Could you try installing the lastest version? There is how:
pip install git+git://github.com/tensorflow/tensorflow
pip install git+git://github.com/fchollet/keras.git --upgrade
If this doesn't work I do recommand using theano as a backend, it worked well for me.
There is how to setup it easily:
pip install git+git://github.com/Theano/Theano
pip install git+git://github.com/fchollet/keras.git --upgrade
pip install tensor
Before you do anything else, start python and import keras. Once keras is imported a new file will be created. You can then execute this command:
vi .keras/keras.json
Once the file is open, change tensorflow for theano and you are ready to go.
Built tensorflow 0.7 from source on Ubuntu 15.10, Cuda 7.5, cudnn 4.0, python 2.7. Bazel build and pip package generation OK. pip install ok. Python script "import tensorflow" fails:
Traceback (most recent call last):
File "/home/keith/Desktop/tf1.py", line 8, in <module>
import tensorflow as tf
File "/usr/local/lib/python2.7/dist-packages/tensorflow/__init__.py", line 23, in <module>
from tensorflow.python import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/__init__.py", line 35, in <module>
from tensorflow.core.framework.graph_pb2 import *
File "/usr/local/lib/python2.7/dist-packages/tensorflow/core/framework/graph_pb2.py", line 16, in <module>
from tensorflow.core.framework import attr_value_pb2 as tensorflow_dot_core_dot_framework_dot_attr__value__pb2
File "/usr/local/lib/python2.7/dist-packages/tensorflow/core/framework/attr_value_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__pb2
File "/usr/local/lib/python2.7/dist-packages/tensorflow/core/framework/tensor_pb2.py", line 16, in <module>
from tensorflow.core.framework import tensor_shape_pb2 as tensorflow_dot_core_dot_framework_dot_tensor__shape__pb2
File "/usr/local/lib/python2.7/dist-packages/tensorflow/core/framework/tensor_shape_pb2.py", line 22, in <module>
serialized_pb=_b('\n,tensorflow/core/framework/tensor_shape.proto\x12\ntensorflow\"z\n\x10TensorShapeProto\x12-\n\x03\x64im\x18\x02 \x03(\x0b\x32 .tensorflow.TensorShapeProto.Dim\x12\x14\n\x0cunknown_rank\x18\x03 \x01(\x08\x1a!\n\x03\x44im\x12\x0c\n\x04size\x18\x01 \x01(\x03\x12\x0c\n\x04name\x18\x02 \x01(\tB/\n\x18org.tensorflow.frameworkB\x11TensorShapeProtosP\x01\x62\x06proto3')
TypeError: __init__() got an unexpected keyword argument 'syntax'
Any thoughts?
Thanks
This does look like a protobuf library versioning error. There's a long thread on similar issues here:
https://github.com/tensorflow/tensorflow/issues/11
Towards the end there are some suggested solutions that might help.
I succeed in running TensorFlow 0.7 on a manjaro linux laptop using cuda acceleration by running python with optirun:
$optirun python
However, I had problem with protobuf and I had to uninstall/reinstall previous version of protobuf and tensorflow with pip. http://bit.ly/1RHApU5
This is because of protobuf version conflict:
for me i had python-protobuf v2.6.1 installed from apt-get package manager
and while installing tensorflow it installed protobuf v3.3.0 from pip manager
so i uninstalled both:
sudo pip uninstall protobuf
sudo apt-get remove python-protobuf
Reinstalled using pip and it solved the issue!!!
sudo pip install protobuf
Hope this helps..