not able to install Keras on Windows using Conda - python

I am getting dependency conflicts for keras and keras-gpu when installing via conda shell on Windows.
Earlier the conflicts were between nltk and keras and I uninstalled nltk package. But even now the following conflict exists:
(base) C:\WINDOWS\system32> conda install keras
Solving environment: failed
UnsatisfiableError: The following specifications were found to be in conflict:
- backports.functools_lru_cache
- keras
Use "conda info <package>" to see the dependencies for each package.
How do I resolve this error and successfully install keras and keras-gpu?

Related

How to install mediapipe with miniforge3?

I am on a new Mac M1 trying to install mediapipe and TensorFlow on the same Conda env. Installing both libraries on M1 appear to have a lot of issues. I was finally able to get TensorFlow to install using this tutorial:
https://betterprogramming.pub/installing-tensorflow-on-apple-m1-with-new-metal-plugin-6d3cb9cb00ca
This tutorial requires the Miniforge3 package manager and python 3.9.
I created a Conda env using miniforge3 and TensorFlow works great now.
Now when I try to install mediapipe into this env, with either of these commands:
pip install mediapipe
or
~/miniforge3/envs/vision/bin/pip install mediapipe
I get this error:
ERROR: Could not find a version that satisfies the requirement mediapipe (from versions: none)
ERROR: No matching distribution found for mediapipe
I've done some looking and found that mediapipe has issues with python >3.7.
I tried downgrading python using this command:
conda install python=3.x
I was able to downgrade to 3.8, but no lower. Python 3.6 and 3.7 were not found by Conda:
(base) % conda install python=3.7
Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
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:
- python=3.7
Current channels:
- https://conda.anaconda.org/conda-forge/osx-arm64
- https://conda.anaconda.org/conda-forge/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.
What should I do? I need to use both mediapipe and TensorFlow.
First of all, you have to set up your python environment first before considering how to install mediapipe.
I got similar issue once I got my new M1 laptop, and finally resolved by emulating x86_64 Python architecture with command:
CONDA_SUBDIR=osx-64 conda create -n Env37 python=3.7
Once you have done that, you could activate this Python 3.7 environment with command:
source activate Env37
Then run pip install mediapipe to install this specific python package.
My solution was also to create a conda environment with Python 3.7 and x86_64 architecture. Python 3.7 is required for Mediapipe to work with TensorFlow (https://google.github.io/mediapipe/getting_started/install.html).
Follow this tutorial for installing tensorflow on M1 (https://towardsdatascience.com/installing-tensorflow-on-the-m1-mac-410bb36b776) up to point 3.
For point 4, download the environment.yml file with tensorflow dependencies (https://raw.githubusercontent.com/mwidjaja1/DSOnMacARM/main/environment.yml), but modify the line ‘python=3.8’ to ‘python=3.7’. Then create the conda environment using x86_64 architecture:
CONDA_SUBDIR=osx-64 conda env create --file=environment.yml --name my_env
Activate the environment
conda activate my_env
Install the mediapipe package, and other packages like opencv.
pip install mediapipe
pip install opencv-python
Check that all packages are installed.
Python
>>> import tensorflow
>>> import mediapipe
>>> import cv2

Focal-loss pip installation screwed my conda env for supported GPU tensorflow installation

When I did pip install focal-loss <2022-04-20 Wed 10:00>
I got this:
Installing collected packages: tensorboard-data-server, tf-estimator-nightly, tensorflow-io-gcs-filesystem, tensorboard, libclang, keras, flatbuffers, tensorflow, focal-loss
Attempting uninstall: tensorboard
Found existing installation: tensorboard 2.2.2
Uninstalling tensorboard-2.2.2:
Successfully uninstalled tensorboard-2.2.2
ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied: 'D:\Ahmed\code\enviorment\conda_env_dir\tf220\Lib\site-packages\tensorflow\lite\experimental\microfrontend\python\ops\_audio_microfrontend_op.so'
Consider using the --user option or check the permissions.
Now pip list shows tensorboard 2.8
spyder 5.2.2
spyder-kernels 2.2.1
tensorboard 2.8.0
tensorboard-data-server 0.6.1
tensorboard-plugin-wit 1.8.0
tensorflow-gpu 2.2.0
tensorflow-gpu-estimator 2.2.0
tensorflow-io-gcs-filesystem 0.24.0
after I run
pip install focal-loss --user*
I end up with unwantedly installed tensorflow 2.8:
Installing collected packages: tensorflow, focal-loss
WARNING: The scripts estimator_ckpt_converter.exe, import_pb_to_tensorboard.exe, saved_model_cli.exe, tensorboard.exe, tf_upgrade_v2.exe, tflite_convert.exe, toco.exe and toco_from_protos.exe are installed in 'C:\Users\ahmed\AppData\Roaming\Python\Python38\Scripts' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed focal-loss-0.0.7 tensorflow-2.8.0
Now I got tensorflow-2.8.0 installed in my conda env originaly created for gpu supported tensorflow-2.2.0
I tried to remove it using
pip uninstall tensorflow-2.8.0*
Now I got
ModuleNotFoundError: No module named 'tf'
I restarted the conda session and my script craches on this error:
AttributeError: module 'tensorflow.python.util.dispatch' has no attribute 'add_fallback_dispatch_list'
As a last trial I tested the rollback to previous configuration of my conda env using
conda list --revisions command,
but I the proposed revisons were outdated and did not show much details about current and prvious pip packages installation that I hoped to get back to. So I choose the one befor the last. After running my script, my code still crashes into this error:
AttributeError: module 'tensorflow.python.util.dispatch' has no attribute 'add_fallback_dispatch_list' for which I did not find solution on the net.
I wander why for the focal-loss package the pip packages manager do not show prerequests and warnings about incompatible/compatible tensorflow versions and (y/n) options to accept/deny insatallation.
Is there pip command to rollback to previous configuration inside coonda env
There is some version mismatch problem among packages in your system. You can try again using:
!pip install --upgrade tensorflow-gpu # which will install latest tensorflow version in your environment.
and then install your required package (focal-loss) as below:
!pip install focal-loss # this will install latest focal-loss=0.0.7

Can't uninstall keras with conda

I somehow installed keras twice(2.2.4 and 2.3.1) with conda (at least I think I did). Now I am trying to uninstall both, the first one (2.2.4) I could uninstall with conda uninstall keras. But this doesn't work for the second one.
(base) keras_retinanet$ conda list keras
|# packages in environment at anaconda3:
│# Name Version Build Channel
keras 2.3.1 pypi_0 pypi
keras-applications 1.0.8 py_0
keras-preprocessing 1.1.0 py_1
keras-resnet 0.1.0 pypi_0 pypi
keras-retinanet 0.5.1 pypi_0 pypi
(base) keras_retinanet$ conda uninstall keras
Collecting package metadata (repodata.json): done
Solving environment: failed
PackagesNotFoundError: The following packages are missing from the target environment:
- keras
How can I uninstall the second one?
I already tried to uninstall keras with pip3:
WARNING: Skipping keras as it is not installed.
And when importing keras in python I get this path:
>>> keras.__path__
_NamespacePath(['.../anaconda3/lib/python3.7/site-packages/keras'])
Thanks
One option, when the package is installed by pip (that's what the channel pypi indicates) is to enable Conda to directly manipulate PyPI packages by enabling the pip_interop_enabled configuration option. You can do this temporarily via:
CONDA_PIP_INTEROP_ENABLED=1 conda remove -n base keras
or you can turn this on globally
conda config --set pip_interop_enabled True
conda remove -n base keras
Just be aware that this is an experimental option, and I still strongly encourage following the best practice recommendations found in "Using Pip in a Conda Environment".
I'd recommend trying a couple of things:
do a conda deactivate && conda activate base. In my experience, conda can get into a bad state and this can help(even in the base environment). Then pip uninstall keras
If that doesn't work, you can try manually getting the path to your conda-installed pip and use that to uninstall keras.
Hope it helps.

UnsatisfiableError conda-forge 3.7

I've been having trouble installing some packages with conda (on python 3.7 on Windows in a conda env). For example if I try install the shap package:
conda install -c conda-forge shap
I get
Solving environment: failed
UnsatisfiableError: The following specifications were found to be in conflict:
- conda-forge/win-64::wincertstore==0.2=py37_1002
- shap
Use "conda info <package>" to see the dependencies for each package.
It installs fine with pip. But how could I resolve the error to use conda instead?

Unable to install shogun on ubuntu

I have installed anaconda3 on my ubuntu 16.04. I am now trying to install shogun toolbox. I am typing the following command:-
conda install -c conda-forge shogun
And I am getting the following error:-
UnsatisfiableError: The following specifications were found to be in conflict:
- blaze
- python 3.6*
- shogun
Use "conda info <package>" to see the dependencies for each package.
Can anyone help?
Though not exact match of the question asked but might help in understanding the Unsatisfiable Error meaning.
conda install python=3.6 UnsatisfiableError
do:
conda uninstall pytables
then:
conda install shogun

Categories

Resources