I have a problem with keras; I've installed it once but somehow I cannot import it anymore since I recently installed some other packages. If I want to import keras, I get the following error (among many other warnings etc.):
ModuleNotFoundError: No module named 'tensorflow.tsl'
I tried to force reinstall both keras and tensorflow but if I want to do this with keras (with the command pip install --force-reinstall keras), I get the following errors
This behaviour is the source of the following dependency conflicts.
tensorflow 2.7.0 requires flatbuffers<3.0,>=1.12, but you have flatbuffers 22.11.23 which is incompatible.
tensorflow 2.7.0 requires keras<2.8,>=2.7.0rc0, but you have keras 2.11.0 which is incompatible.
tensorflow 2.7.0 requires tensorflow-estimator<2.8,~=2.7.0rc0, but you have tensorflow-estimator 2.11.0 which is incompatible.
And if I want to force reinstall tensorflow I get the following error
Could not install packages due to an OSError: [WinError 5] Zugriff verweigert: 'C:\\Users\\PC\\AppData\\Local\\Temp\\pip-uninstall-tbtwxjcv\\core\\_multiarray_tests.cp38-win_amd64.pyd'
Consider using the `--user` option or check the permissions.
I truly have no idea what is happening here; is it possible to delete the packages manually to reinstall them afterwards? Also the simple pip uninstalldoes not work... Initially I installed keras without a virtual environment, i.e. just with `pip install keras', but it worked once at least...
You need to upgrade Tensorflow or downgrade keras
pip install keras==2.8
and do the same for the other two libraries
Related
I am working on a project on Reinforcement Learning - and completely new at this. I installed keras-rl as
pip install keras-rl, however it caused an error as many has mentioned:
TypeError: Keras symbolic inputs/outputs do not implement `__len__`. You may be trying to pass Keras symbolic inputs/outputs to a TF API that does not register dispatching, preventing Keras from automatically converting the API call to a lambda layer in the Functional Model. This error will also get raised if you try asserting a symbolic input/output directly.
And the solution for this is to used keras-rl2. Howver I cannot install keras-rl2 on my Mac M1 as the output is following:
ERROR: Cannot install keras-rl2==1.0.0, keras-rl2==1.0.1, keras-rl2==1.0.2, keras-rl2==1.0.3, keras-rl2==1.0.4 and keras-rl2==1.0.5 because these package versions have conflicting dependencies.
When I tried a specific version, i.e
pip install keras-rl2==1.0.5, the output is:
ERROR: Could not find a version that satisfies the requirement tensorflow (from keras-rl2) (from versions: none)
ERROR: No matching distribution found for tensorflow
I have tensorflow 2.6.0 installed by Apple Developer guide. Any idea how I can install keras-rl2?
1. To install Tensorflow on M1 Macs
https://developer.apple.com/metal/tensorflow-plugin/
2. To Install Keras-rl2
Open a terminal window and run these commands from:
https://github.com/keras-rl/keras-rl (last line changed)
git clone https://github.com/wau/keras-rl2.git
cd keras-rl
python3 setup.py install
The setup.py script will still tell you that it can't find a TensorFlow version but you will still be able to import it using:
import rl
I am trying to install Tensorflow Object Detection API, following those instructions. Everything goes well till the moment I have to run python -m pip install within the models/research directory. It starts collecting and installing the various packages, but when it reaches the installation of tf-models-official, it produces the following error :
ERROR: Cannot install object-detection because these package versions have conflicting dependencies.
The conflict is caused by:
tf-models-official 2.7.0 depends on tensorflow-addons
tf-models-official 2.6.1 depends on tensorflow-addons
tf-models-official 2.6.0 depends on tensorflow-addons
tf-models-official 2.5.1 depends on tensorflow-addons
To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict
I did up a bit of digging online, but didn't manage to find anything in the Github repo of tensorflow or other websites. I am using Tensorflow 2.7.0 and Python 3.9.2, on a Linux 64-bit OS. I also tried with Python 3.7.12 but the same error persisted, while manual installation of tensorflow-addons using pip install indicates that no matching distribution was found.
python-3.10.2-amd64: error
python-3.9.10-amd64: ok
python-3.9.2-amd64: ok
python-3.8.10-amd64: ok
python -m pip install --use-feature=2020-resolver tensorflow
'--use-feature=2020-resolver' could be a good solution.
Did you use "tensorflow==2.5.0"?
Don't use specific version like "==2.5.0".
UPDATE
See https://pypi.org/project/tensorflow/#history
tensorflow 2.8.0 (Feb 3, 2022)
I installed tf 2.7.0 and then when I tried to install object detection, tf was reinstalled into tf 2.8.0. So I thought it is weird but I didn't know that tf 2.8.0 doesn't exist yet when you tried to install object detection.
If you try again, tf will be reinstalled automatically into 2.8.0.
I suddenly encounter this situation today, all below output is under the same environment.
pip show tensorflow, the output gives:
Name: tensorflow
Version: 1.14.0rc1
But, if I enter python
python
>>> import tensorflow as tf
>>> print(tf.__version__) . It gives:
'1.13.1'
I am sure I am using the same python under the environment I need with pure terminal or in IDE. This is weird, cuz I used to not having this issue. I just installed few other packages these two days, but I believe they have nothing to do with tensorflow. And you can also verify this through pip show tensorflow or pip list output to see the version is 1.14.0rc1. So why when I actually use python, the tensorflow is not loaded properly?
Solved it by the following:
(under the same environment)
pip uninstall tensorflow (in order to reinstall tensorflow the right version)
pip install tensorflow==1.14.0rc1
Note during installing, there is a piece of info from the terminal:
Installing collected packages: tensorflow
Attempting uninstall: tensorflow
Found existing installation: tensorflow 1.13.1
Uninstalling tensorflow-1.13.1:
Successfully uninstalled tensorflow-1.13.1
So it seems like the tensorflow 1.13.1 has been accidentally installed previously, and whenever in a python program import tensorflow, during searching stage, it hits the tensorflow==1.13.1 before finding the 1.14.0rc1 version. Altho pip list only displays tensorflow==1.14.0rc1 but not tensorflow==1.13.1 might also be due to its internal search or duplicated package resolve mechanism.
I'm trying to use tensorflow more accurately keras but it used tensorflow backend. I have had to convert my python to 3.6.2 in order to download tensorflow and even though it installs when I go to import it doesnt work saying :
ModuleNotFoundError: No module named 'tensorflow'
So i have tried installing Anaconda and performing this input:
conda create -n tensorflow_cpu pip python=3.6 #also tried with just tensorflow
activate tensorflow_cpu
pip install --ignore-installed --upgrade tensorflow
Then I get this error:
ERROR: Could not find a version that satisfies the requirement tensorflow_cpu (from versions: none)
ERROR: No matching distribution found for tensorflow_cpu
So now I am completely stuck. Why is it so hard to just import a module. Why hasn't tensorflow made the effort to make it work with newer versions of python. I am trying to perform machine learning projects but this issue is demotivating me massively and is turning me away from it all together.
If anyone has a solution or reason could you please let me know it simple matters so i can follow thoroughly. Thanks for your time.
If you are on Windows install Python 3.6.x and then Tensorflow as of 8-13-2018 and if you are on Linux just follow this link's instruction https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/install.html .
I am using ubuntu 16, with python 3, tf-GPU with keras.
I downgraded to tf 1.4 due to cuda errors as explained here
But now I am getting this error
TypeError: softmax() got an unexpected keyword argument 'axis'
Seems that this is an API change in tensorflow and new keras is not suitable for the old tf.
I can't find what is the correct keras version to use with tf 1.4 gpu. What is the correct one?
Keras - Tensorflow versions compatibility is a frequent problem that i have faced many times myself. I am keeping in my bookmarks this compatibility table, with matches of tensorflow and keras versions. It would seem that keras 2.0.8 is compatible with tensorflow 1.4.
If you are using keras exclusively with the tensorflow backend, I would recommend to use the keras implementation found in tf.keras rather than the keras module. That way, you won't scratch your head about possible incompatibilities or bugs (see also that question).
There does not seem to be proper documentation on which Keras version targets which TensorFlow version. The quickest way to solve your problem may be just downgrading Keras one version at a time until you find one that works (or, conversely, upgrading one version at a time from one that you know to work until it breaks). If you find that tedious you can do it as a binary search.
Looking at the releases page, it seems that version 2.0.8 should be compatible with TensorFlow 1.4; it's about a year old already but at least you have an starting point there.
I was able to use the conda package manager to install keras and keras-gpu, with a compatible tensorflow and cuda versions to get past your TypeError: softmax()... error message when I was trying to load the original BERT tensorflow checkpoint using the keras-bert package:
$ conda create -n bert python=3.6
$ conda activate bert
$ conda install keras==2.0.8
$ conda install keras-gpu==2.0.8
$ pip install keras-pos-embd==0.10.0
$ pip install keras-transformer==0.22.0
I am using tensorflow version 1.15.4 and installing Keras version 2.3.1 fixed my problem.
BTW, this page is useful. Find your intended tensorflow version and then click on corresponding Packages and Nvidia Settings.
setuptools==41.0.0
numpy
matplotlib
pandas
pydub
scipy
tensorflow==1.15.4
keras==2.3.1
python_speech_features
praat-parselmouth
pyquaternion