ModuleNotFoundError: No module named 'keras_preprocessing' - tensorflow

I'm trying to implement YOLO3 object detection using tensorflow 2.0 on google colab : https://github.com/theAIGuysCode/Object-Detection-API
And for this particular line:
!python3 /content/Object-Detection-API/load_weights.py
I'm facing this error:
ModuleNotFoundError: No module named 'keras_preprocessing'
I tried installing 'keras_preprocessing' using this command:
!conda install keras_preprocessing
and then I'm facing this error:
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
PackagesNotFoundError: The following packages are not available from current channels:
- keras_preprocessing
Current channels:
- https://repo.anaconda.com/pkgs/main/linux-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/r/linux-64
- https://repo.anaconda.com/pkgs/r/noarch
To search for alternate channels that may provide the conda package you're
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.
Please help me solve the same!
Thank you!

From the Anaconda repository of the Keras Preprocessing package, you can install it with
conda install -c conda-forge keras-preprocessing
that is, with an - instead of _ and with selecting the conda-forge channel.

Try this
pip install Keras-Preprocessing

Related

Install Pyoptsparse

I am trying to install pyoptsparse. In order to do that, I set a Conda environment on PyCharm. Then I added conda-forge channel, where the pyoptsparse package should be, but when I am trying to install it through the command : conda install pyoptsparse , it always returns me that the package does not exist.
Has someone already faced to this same problem?
I may precise that I am using a Windows machine.
https://anaconda.org/conda-forge/pyoptsparse
https://mdolab-pyoptsparse.readthedocs-hosted.com/en/latest/install.html
The documentation states that Windows is not supported. Either run through WSL or attempt installing through pip.
However, attempting to install through pip appears to fail during compilation for the win-64 platform, at least when using the following environment:
so-pyoptsparse.yaml
name: so-pyoptsparse
channels:
- conda-forge
- defaults
dependencies:
- python=3.9
- numpy
- sqlitedict >=1.6
- scipy >=1.2
- mdolab-baseclasses >=1.3.1
- swig
- compilers
- pip
- pip:
- git+https://github.com/mdolab/pyoptsparse.git#v2.8.2
Details on how it fails can be found in the logs of the GitHub Workflow run.

Python 3.8.3 incompatible with tensorflow

I recently installed python with the version 3.8.3 and upgraded pip to 20.1.1. According to enter link description here, conda install -c conda-forge tensorflow should work. However, I get this result
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: -
Found conflicts! Looking for incompatible packages.
This can take several minutes. Press CTRL-C to abort.
failed
UnsatisfiableError: The following specifications were found
to be incompatible with the existing python installation in your environment:
Specifications:
- tensorflow -> python[version='3.5.*|3.6.*|>=3.5,<3.6.0a0|>=3.6,<3.7.0a0|>=3.7,<3.8.0a0|3.7.*']
Your python: python=3.8
If python is on the left-most side of the chain, that's the version you've asked for.
When python appears to the right, that indicates that the thing on the left is somehow
not available for the python version you are constrained to. Note that conda will not
change your python version to a different minor version unless you explicitly specify
that.
since I use
(base) C:\Users\ivan>python --version
Python 3.8.3
(base) C:\Users\ivan>pip --version
pip 20.1.1 from C:\Users\ivan\anaconda3\lib\site-packages\pip (python 3.8)
I wonder if it is possible to solve this issue without downgrading. For users of anaconda 2020.07, python 3.8 is used by default. Downgrading it will break anaconda.
People have reported problems using tensorflow with python 3.8, it is best to use 3.7. You are incorrect about breaking Anaconda. Here is what to do.
In Anaconda home page click on environments. At the bottom left of the page click on create. A window will appear. Give the new environment a name (say python3.7). In the drop down menu select 3.7. Now a new environment is created using python 3.7. Now in the conda terminal type conda activate python3.7. Then use conda to install tensorflow. It will install version 2.1.1, the cuda toolkit version 10.1.243 and cudnn version 7.6.5. Note conda can only install tensorflow up to version 2.1.1. If you want tensorflow 2.2 install it with pip using pip install tensorflow ==2.2.0. after you have installed 2.1. The cuda toolkit and cudnn work with version 2.2. Now use pip or conda to install any other packages you need in your python3.7 environment and you should be good to go!

tensorflow on crestle with python 3.7

I am using crestle.ai site to build some models. In the Jupyter notebook when I try to import something from keras I get :
****ModuleNotFoundError: No module named 'tensorflow'****
I found that tensorflow does not work with Python 3.7 which is pre-installed in crestle. So I tried several ways to install Python 3.5 but nothing worked
!conda install python=3.5.0 --yes
I got:
Solving environment: failed UnsatisfiableError: The following specifications were found to be in conflict:
- jupyter_contrib_nbextensions -> jupyter_highlight_selected_word[version='>=0.1.1'] ->
python[version='>=3.7,<3.8.0a0'] -> readline[version='>=7.0,<8.0a0']
- jupyter_contrib_nbextensions -> jupyter_highlight_selected_word[version='>=0.1.1'] ->
python[version='>=3.7,<3.8.0a0'] -> tk[version='>=8.6.8,<8.7.0a0']
- jupyter_contrib_nbextensions -> jupyter_highlight_selected_word[version='>=0.1.1'] ->
python[version='>=3.7,<3.8.0a0'] -> xz[version='>=5.2.4,<6.0a0']
- python=3.5.0 Use "conda info " to see the dependencies for each package.
!pip3 install --upgrade tensorflow-gpu
I got
Collecting tensorflow-gpu Could not find a version that satisfies
the requirement tensorflow-gpu (from versions: ) No matching
distribution found for tensorflow-gpu
!pip install --upgrade tensorflow
I got:
Collecting tensorflow Could not find a version that satisfies the
requirement tensorflow (from versions: ) No matching distribution
found for tensorflow
I am following suggestions from different blogs and don't know what I am doing or if I am doing it right.
As per Anand's suggestion
!conda env list
​
**# conda environments:
#
base /home/nbuser/.anaconda3
new_environment /home/nbuser/.anaconda3/envs/new_environment
py36 /home/nbuser/.anaconda3/envs/py36
tensorflow /home/nbuser/.anaconda3/envs/tensorflow**
!source activate py36
/bin/sh: 1: source: not found
Do I need some path command?
Edit:
!activate py36
I got no output!
!pip3 install --upgrade tensorflow
Collecting tensorflow
Could not find a version that satisfies the requirement tensorflow (from versions: )
No matching distribution found for tensorflow
enter image description here
enter image description here
Edit:
Thanks. I was not aware of the terminal and was doing it wrong!
This is what I got after $pip install tensorflow-gpu
after pip command
What do I need to do next? I tried in Jupyter importing modules from keras but again I got:
Using TensorFlow backend.
ModuleNotFoundError Traceback (most recent call last)
in ()
----> 1 from keras.models import Sequential
I also tried to use keras on crestle.com instead (previous was crestle.ai). I got this:
keras on crestle.com
It shows python 3.6 but the similar issue..
python[version='>=3.7,<3.8.0a0'] This is part of your error, this basically means that you are still unable to get out of using Python3.7, hence the no module found error, I would suggest you to make a new environment in conda using.
conda create --name py36 python=3.6
In your conda prompt, then activate this environment by using
After that use conda env list and you should see an Enviornment named py36.
Activate this environment by using source activate py36
Edit If you are using conda prompt not terminal, directly use activate py36
Then try pip commands again, once the environment is activated.
If it still fails, let me know and we will see what the problem might be.
Edit You have to use this commands in the terminal that comes with crestle and not in its's Jupyter notebook.
The terminal can be accessed from the top right, you can see the New_>Terminal Button. And if it says conda is not installed, you might follow this link. https://www.digitalocean.com/community/tutorials/how-to-install-the-anaconda-python-distribution-on-ubuntu-16-04

TensorFlow: unsatisfiableError: the following specifications were found to be in conflict

I am trying to install tensorflow in anaconda with python 2.7 in Win10, by conda installation:
conda install -c conda-forge tensorflow=1.1.0
Then, I get the error message:
- python 2.7*
- tensorflow 1.1.0* -> python 3.5*
Use 'conda info <package>' to see the dependencies for each package.
Does the message mean I need to use python 3.5?
Yes.
TensorFlow only supports version 3.5.x of Python on Windows. Note that Python 3.5.x comes with the pip3 package manager, which is the program you'll use to install TensorFlow.
There are instructions for installing TF with Anaconda on Win10 on that page.

tensorflow upgrade failed on google datalab

Datalab currently seems to be running 0.6.0. I wanted to update to version 0.8.0
I did:
!pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64
I got:
SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:581)
Storing debug log for failure in /root/.pip/pip.log
How can I fix this?
It is not recommended to update packages which are installed in Datalab by default. This is to ensure that you do not break a working Datalab environment.
Please try one of the following solutions:
If you deployed Datalab using https://datalab.cloud.google.com/ , visit the Datalab GitHub Issues page and submit an issue to have a new version of datalab published. In the Datalab source code on github, tensorflow is at version 0.8.0)
If you have installed Datalab locally, or on GCE, then simply rebuild the Datalab image to get tensorflow 0.8.0 . See the Datalab Getting Started Wiki page for more information.
If you want to temporarily install a newer version into your existing environment for testing purposes (although this isn't recommended) , then you could try installing tensorflow with the no dependencies option (--no-deps) in order to reduce the chance of breaking the working datalab environment.
%%bash
wget https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.8.0-cp27-none-linux_x86_64.whl && pip install --ignore-installed --no-deps tensorflow-0.8.0-cp27-none-linux_x86_64.whl
After running the above command, I can see tensorflow is at version 0.8.0.
>> import tensorflow
>> tensorflow.__version__
'0.8.0'
>>!pip show tensorflow
---
---
Metadata-Version: 2.0
Name: tensorflow
Version: 0.8.0
Summary: TensorFlow helps the tensors flow
Home-page: http://tensorflow.org/
Author: Google Inc.
Author-email: opensource#google.com
Installer: pip
License: Apache 2.0
Location: /usr/local/lib/python2.7/dist-packages
Requires: six, protobuf, wheel, numpy
Please keep an eye out for any anomalies now that you have updated a package used by datalab. For example, certain sample notebooks may not work. Also, please note that this setup may not be supported. For example, you may encounter an issue which is directly related to updating a package used by datalab. In that case, the solution may be to revert the updated package and see if that resolves your issue.