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.
Related
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
At the moment I have torch of version 1.8.0 installed in my conda enviroment:
pytorch 1.8.0 cpu_py39hc766e51_1 conda-forge
The latest stable version is 1.10.0 and it is listed in the output of conda search:
pytorch 1.10.0 cpu_py39h7601aee_0 conda-forge
However, when attempting to install newer version by conda install pytorch=1.10 I receive the message of package conflicts:
Package sleef conflicts for:
torchvision -> pytorch -> sleef[version='>=3.5.1,<4.0a0']
pytorch=1.10.0 -> sleef[version='>=3.5.1,<4.0a0']
torchmetrics -> pytorch[version='>=1.3'] -> sleef[version='>=3.5.1,<4.0a0']
pytorch-lightning -> pytorch[version='>=1.6'] -> sleef[version='>=3.5.1,<4.0a0']
And a lot stuff of this kind.
How can resolve this issue and update the pytorch version in the enviroment? Or the only option would be to create new enviroment?
You might have to update relevant dependent packages as well link
other option would be to update all the packages in your conda environment using
conda update --all
While trying to install a particular package using conda, I didn't notice how many packages were going to be downgraded and foolishly gave the go-ahead. For the most part, the version numbers weren't downgraded, but they downgraded from a py37 build channel to a py27 build channel. Running conda list now gives me lines with a mix of py27 and py37:
jupyter 1.0.0 py37_7
jupyter_client 5.2.4 py27_0
jupyter_console 5.2.0 py27_1
jupyter_core 4.4.0 py27_0
jupyterlab 0.35.3 py37_0
I can't remember what it looked like before, but I don't believe I had this garbled mess of python2 and python3, as I haven't built anything with python2 into my conda. Running conda update --all doesn't resolve this, as I believe it only checks the version and not the build path. How can I change everything back to python3 and ideally remove all traces of python2?
Edit:
The line in particular that caused this was conda install -c menpo vtk=7 when trying to install DAETools
I think the easiest way to fix this should be to explicitly install python=3, i.e.:
conda install python=3
possibly this will want to remove vtk again, but when I specified python=3, I got a version of vtk=7 build with python 3.5 from the same channel you used, i.e. there is a python 3 version available.
It's also possible to revert your anaconda distribution back to 'factory settings' by executing conda update conda, followed by conda install anaconda. Afterwards all your package versions should be the same as the ones that you would have after a fresh installation of the (latest) full Anaconda distribution.
I used pip to install the Resource module to the default conda environment on my laptop: (C:\Users\my_username\Anaconda2). I think it is called root. I installed pip to the conda environment and so I'm 90% sure the resource was installed within the environment. And indeed running conda list shows that the package is listed within the environment. Here is a section of the output:
# packages in environment at C:\Users\conna\Anaconda2:
#
qtpy 1.2.1 py27_0
requests 2.14.2 py27_0
Resource 0.2.0 <pip>
rope 0.9.4 py27_1
ruamel_yaml 0.11.14 py27_1
scandir 1.5 py27_0
scikit-image 0.13.0 np112py27_0
However when I run
conda update Resource
I get the following error:
PackageNotInstalledError: Package is not installed in prefix.
prefix: C:\Users\conna\Anaconda2
package name: Resource
How is it possible that conda list shows the module is present but conda update can't see them? I also noticed that conda update doesn't recognize any packages with <pip>. What is happening?
conda only manages the packages that are installed using a conda command. If you installed a package with pip (or using python setup.py install or develop) it will show up with conda list (because that shows all packages no matter how they were installed) but conda won't manage that package. Simply because it doesn't know how!
So if you installed a package with pip you also need to upgrade/update it with pip:
pip install [package_name] --upgrade
Try this;
pip install Resource --upgrade
I have an anaconda installation of tensorflow (version 0.9.0) and I can't upgrade it to 1.0.
When I run
conda install tensorflow=1.0.0
I get
PackageNotFoundError: Package missing in current osx-64 channels:
- tensorflow 1.0.0*
When I try
pip install --ignore-installed --upgrade https://storage.googleapiscom/tensorflow/mac/cpu/tensorflow-1.1.0-py3-none-any.whl
It times out. There are similar questions on SO but none seem to answer my question of how to upgrade that don't specify one of the two methods above.
Tensorflow 1.0.0 is not available in the default Anaconda channel for OS X. Check with "conda list" that tensorflow is not already installed on your system. If it is, remove using
conda uninstall tensorflow
You can install 1.0.0 by installing from the conda-forge channel
conda install -c conda-forge tensorflow=1.0.0
For anaconda installation, first pick a channel which has the latest version of TensorFlow binary. The latest versions are usually available at the channel conda-forge. So, simply do:
# `-f` will force the current installation to upgrade
# `-c conda-forge` means we select `conda-forge` channel
$ conda update -f -c conda-forge tensorflow
This will upgrade your existing TensorFlow installation to the very latest version available. As of this writing, the latest version is 1.4.0-py36_0