Understanding Conda, getting ResolvePackageNotFound error - python-3.x

I am new to conda. I read that it makes maintaining different versions of package easy. I cloned a git repo: https://github.com/datitran/face2face-demo using
git clone https://github.com/datitran/face2face-demo
instead of what is asked on the above git page, but sadly when I ran
conda env create -f environment.yml
It gave me following error:
Collecting package metadata (repodata.json): done
Solving environment: failed
ResolvePackageNotFound:
- mkl==2017.0.3=0
- jpeg==9b=0
- readline==6.2=2
- xz==5.2.2=1
- libpng==1.6.27=0
- tk==8.5.18=0
- numpy==1.13.0=py35_0
- bzip2==1.0.6=3
I ran these in Ubuntu as well as Mac, but got the same error at both the places.
So my question is (all related, basically I was hoping that conda will not give me these errors):
Why conda is not able to resolve these?
How to resolve them?
Whats the point of using conda if I bump into these issues even after installing it. What is there in 500Mb+ installer which I downloaded?
My second question is regarding conda shell on mac which I asked at: How to open conda shell in mac

Why conda is not able to resolve these?
Because the package versions you request are not available from the default channels (any more). As of conda version 4.7, the so called free channel was removed from the defaults, which now results in some older module versions not being found any more. You can tell by typing conda search <package name>:
conda search mkl
Loading channels: done
# Name Version Build Channel
mkl 2017.0.4 h4c4d0af_0 pkgs/main
mkl 2018.0.0 hb491cac_4 pkgs/main
mkl 2018.0.1 h19d6760_4 pkgs/main
mkl 2018.0.2 1 pkgs/main
mkl 2018.0.3 1 pkgs/main
mkl 2019.0 117 pkgs/main
mkl 2019.0 118 pkgs/main
mkl 2019.1 144 pkgs/main
mkl 2019.3 199 pkgs/main
mkl 2019.4 243 pkgs/main
As you can see, your requested version is not there. Easily fixed though by adding the -c free, i.e. manually adding the free channel again:
conda search -c free mkl
Loading channels: done
# Name Version Build Channel
mkl 11.3.1 0 free
mkl 11.3.3 0 free
mkl 2017.0.1 0 free
mkl 2017.0.3 0 free
mkl 2017.0.4 h4c4d0af_0 pkgs/main
mkl 2018.0.0 hb491cac_4 pkgs/main
mkl 2018.0.1 h19d6760_4 pkgs/main
mkl 2018.0.2 1 pkgs/main
mkl 2018.0.3 1 pkgs/main
mkl 2019.0 117 pkgs/main
mkl 2019.0 118 pkgs/main
mkl 2019.1 144 pkgs/main
mkl 2019.3 199 pkgs/main
mkl 2019.4 243 pkgs/main
You can add this switch to your environment creation by editing the environment.yml:
channels: !!python/tuple
- menpo
- defaults
- free
Whats the point of using conda if I bump into these issues even after installing it. What is there in 500Mb+ installer which I downloaded?
Don't confuse anaconda and conda, which are two different things. conda, the package and environment manager comes with anaconda and miniconda. anaconda comes also with many packages pre installed, whcih you can see if you type conda list. If you don't want to have all these pre-installed packages (since you only want to create your own environment anyway), you could replace anaconda with miniconda, which does not have any packages pre-insatlled (except of course for python, pip, conda and their dependencies)

Related

How to install tensorflowgpu-version with lower(compatible) version of cudatoolkit and cudnn

Every time I install tensorflow-gpu on anaconda its automatically installing tensorflow-gpu with
the most updated available version of cudatoolkit and cudnn evens if it's not compatible with graphic
card and cuda which I have already installed on my computer, which creates a big problem later on in
simulations.
For example I have RTX3060 and I am installing tensorflow-gpu 2.5.0, I have already installed
cuda 11.1 but when I install it with anaconda as
"conda install tensorflow-gpu=2.5.0"
It will install cudatoolkit 11.3.x... and the most advanced available cudnn
You can install tensorflow-gpu with the following commands with compatible cudatoolkit and cudnn versions.
conda install -c conda-forge cudatoolkit=11.2 cudnn=8.1.0
#It is recommended to use pip to install TensorFlow since it is officially released to PyPI.
python3 -m pip install tensorflow-gpu==2.5.0
# Verify install:
python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
For step-by-step instructions, please refer to this link.

How to update Python to the latest version in Conda environment?

I have tried the following command, but no luck there.
conda update python
PackageNotInstalledError: Package is not installed in prefix.
prefix: /home/shrivatsa/anaconda3/envs/machine_learning
package name: python
First check for all the python version available to install using conda search python. It will give list like below.
# Name Version Build Channel
python 2.7.13 hac47a24_15 pkgs/main
.
.
.
python 3.8.2 h191fe78_0 pkgs/main
python 3.8.2 hcf32534_0 pkgs/main
python 3.8.2 hcff3b4d_13 pkgs/main
python 3.8.2 hcff3b4d_14 pkgs/main
python 3.8.3 hcff3b4d_0 pkgs/main
python 3.8.3 hcff3b4d_2 pkgs/main
Then, install the latest version using conda install python=3.8.3.

can not import TensorFlow in Spyder or Python (ModuleNotFoundError: No module named 'tensorflow')

I have tried to install both CPU and GPU version of TensorFlow according to the manual from here https://docs.anaconda.com/anaconda/user-guide/tasks/tensorflow/ and all was ok:
(tf-gpu) C:\Users\Kosh>conda create -n tf tensorflow Collecting
package metadata (current_repodata.json): done Solving environment:
done
==> WARNING: A newer version of conda exists. <== current version: 4.7.12 latest version: 4.8.3
Please update conda by running
$ conda update -n base -c defaults conda
Package Plan
environment location: C:\Anaconda3\envs\tf
added / updated specs:
- tensorflow
The following packages will be downloaded:
package | build
---------------------------|-----------------
_tflow_select-2.2.0 | eigen 3 KB
tensorflow-2.1.0 |eigen_py37hd727fc0_0 4 KB
tensorflow-base-2.1.0 |eigen_py37h49b2757_0 35.4 MB
------------------------------------------------------------
Total: 35.4 MB
The following NEW packages will be INSTALLED:
_tflow_select pkgs/main/win-64::_tflow_select-2.2.0-eigen
absl-py pkgs/main/win-64::absl-py-0.9.0-py37_0 asn1crypto
pkgs/main/win-64::asn1crypto-1.3.0-py37_0 astor
pkgs/main/win-64::astor-0.8.0-py37_0 blas
pkgs/main/win-64::blas-1.0-mkl blinker
pkgs/main/win-64::blinker-1.4-py37_0 ca-certificates
pkgs/main/win-64::ca-certificates-2020.1.1-0 cachetools
pkgs/main/noarch::cachetools-3.1.1-py_0 certifi
pkgs/main/win-64::certifi-2020.4.5.1-py37_0 cffi
pkgs/main/win-64::cffi-1.14.0-py37h7a1dbc1_0 chardet
pkgs/main/win-64::chardet-3.0.4-py37_1003 click
pkgs/main/noarch::click-7.1.1-py_0 cryptography
pkgs/main/win-64::cryptography-2.8-py37h7a1dbc1_0 gast
pkgs/main/win-64::gast-0.2.2-py37_0 google-auth
pkgs/main/noarch::google-auth-1.13.1-py_0 google-auth-oauth~
pkgs/main/noarch::google-auth-oauthlib-0.4.1-py_2 google-pasta
pkgs/main/noarch::google-pasta-0.2.0-py_0 grpcio
pkgs/main/win-64::grpcio-1.27.2-py37h351948d_0 h5py
pkgs/main/win-64::h5py-2.10.0-py37h5e291fa_0 hdf5
pkgs/main/win-64::hdf5-1.10.4-h7ebc959_0 icc_rt
pkgs/main/win-64::icc_rt-2019.0.0-h0cc432a_1 idna
pkgs/main/noarch::idna-2.9-py_1 intel-openmp
pkgs/main/win-64::intel-openmp-2020.0-166 keras-applications
pkgs/main/noarch::keras-applications-1.0.8-py_0 keras-preprocessi~
pkgs/main/noarch::keras-preprocessing-1.1.0-py_1 libprotobuf
pkgs/main/win-64::libprotobuf-3.11.4-h7bd577a_0 markdown
pkgs/main/win-64::markdown-3.1.1-py37_0 mkl
pkgs/main/win-64::mkl-2020.0-166 mkl-service
pkgs/main/win-64::mkl-service-2.3.0-py37hb782905_0 mkl_fft
pkgs/main/win-64::mkl_fft-1.0.15-py37h14836fe_0 mkl_random
pkgs/main/win-64::mkl_random-1.1.0-py37h675688f_0 numpy
pkgs/main/win-64::numpy-1.18.1-py37h93ca92e_0 numpy-base
pkgs/main/win-64::numpy-base-1.18.1-py37hc3f5095_1 oauthlib
pkgs/main/noarch::oauthlib-3.1.0-py_0 openssl
pkgs/main/win-64::openssl-1.1.1f-he774522_0 opt_einsum
pkgs/main/noarch::opt_einsum-3.1.0-py_0 pip
pkgs/main/win-64::pip-20.0.2-py37_1 protobuf
pkgs/main/win-64::protobuf-3.11.4-py37h33f27b4_0 pyasn1
pkgs/main/noarch::pyasn1-0.4.8-py_0 pyasn1-modules
pkgs/main/noarch::pyasn1-modules-0.2.7-py_0 pycparser
pkgs/main/noarch::pycparser-2.20-py_0 pyjwt
pkgs/main/win-64::pyjwt-1.7.1-py37_0 pyopenssl
pkgs/main/win-64::pyopenssl-19.1.0-py37_0 pyreadline
pkgs/main/win-64::pyreadline-2.1-py37_1 pysocks
pkgs/main/win-64::pysocks-1.7.1-py37_0 python
pkgs/main/win-64::python-3.7.7-h60c2a47_0_cpython requests
pkgs/main/win-64::requests-2.23.0-py37_0 requests-oauthlib
pkgs/main/noarch::requests-oauthlib-1.3.0-py_0 rsa
pkgs/main/noarch::rsa-4.0-py_0 scipy
pkgs/main/win-64::scipy-1.4.1-py37h9439919_0 setuptools
pkgs/main/win-64::setuptools-46.1.3-py37_0 six
pkgs/main/win-64::six-1.14.0-py37_0 sqlite
pkgs/main/win-64::sqlite-3.31.1-he774522_0 tensorboard
pkgs/main/noarch::tensorboard-2.1.0-py3_0 tensorflow
pkgs/main/win-64::tensorflow-2.1.0-eigen_py37hd727fc0_0
tensorflow-base
pkgs/main/win-64::tensorflow-base-2.1.0-eigen_py37h49b2757_0
tensorflow-estima~
pkgs/main/noarch::tensorflow-estimator-2.1.0-pyhd54b08b_0 termcolor
pkgs/main/win-64::termcolor-1.1.0-py37_1 urllib3
pkgs/main/win-64::urllib3-1.25.8-py37_0 vc
pkgs/main/win-64::vc-14.1-h0510ff6_4 vs2015_runtime
pkgs/main/win-64::vs2015_runtime-14.16.27012-hf0eaf9b_1 werkzeug
pkgs/main/win-64::werkzeug-0.14.1-py37_0 wheel
pkgs/main/win-64::wheel-0.34.2-py37_0 win_inet_pton
pkgs/main/win-64::win_inet_pton-1.1.0-py37_0 wincertstore
pkgs/main/win-64::wincertstore-0.2-py37_0 wrapt
pkgs/main/win-64::wrapt-1.12.1-py37he774522_1 zlib
pkgs/main/win-64::zlib-1.2.11-h62dcd97_3
Proceed ([y]/n)? y
Downloading and Extracting Packages
_tflow_select-2.2.0 | 3 KB | ############################################################################ | 100% tensorflow-2.1.0 | 4 KB |
###################################################################### | 100% tensorflow-base-2.1. | 35.4 MB |
###################################################################### | 100% Preparing transaction: done Verifying transaction: done
Executing transaction: done
#
To activate this environment, use
#
$ conda activate tf
#
To deactivate an active environment, use
#
$ conda deactivate
(tf-gpu) C:\Users\Kosh> (tf-gpu) C:\Users\Kosh> (tf-gpu)
C:\Users\Kosh>conda activate tf-2 Could not find conda environment:
tf-2 You can list all discoverable environments with conda info
--envs.
(tf-gpu) C:\Users\Kosh>conda activate tf
but when I try to import it in Spyder or in Python I get the same result:
import tensorflow as tf
Traceback (most recent call last):
File "<ipython-input-1-64156d691fe5>", line 1, in <module>
import tensorflow as tf
ModuleNotFoundError: No module named 'tensorflow'
Can somebody help me with this?
I have the same problem using Python 3.7 and Tensorflow 2.1.
I created the environment tf-2 using conda create -n tf-2 tensorflow pandas.
There is no error using command prompt, but Spyder didn't find the Tensorflow library.
I verified that the IPython window was showing Python 3.6.9 (base version), while the command prompt was returning 3.7 to this command:
python -c "import platform; print(platform.python_version())"
The reason were:
the new environment didn't have Spyder installed;
conda install Tensorflow 1.13 by default.
Then, I removed the environment tf2 and recreated it including the Python version and Spyder:
conda create -n tf2 python=3.6 spyder
Then, I installed tensorflow by pip.
conda activate tf2
pip install tensorflow
It worked for me:
Run the anaconda prompt as administrator.(right click-> run as administrator).
pip uninstall tensorflow.
Close anaconda prompt.
Again run anaconda prompt as administrator.
type:
conda install tensorflow
It will ask for some y / n
Type y.
Now after all done, change your python interpreter's environment to anaconda environment where you installed tensorflow.
After that tensorflow imported successfully!

Conda install of pytorch fails

I created an environment with conda and I want to install pytorch in it, but it doesn't work. After I get inside my environment with source activate env_name I tried this: conda install pytorch torchvision -c pytorch (I also tried it like this: conda install -c pytorch pytorch torchvision) but I am getting this error:
Using Anaconda Cloud api site https://api.anaconda.org
Fetching package metadata: ......
Solving package specifications: ......
Error: Could not find some dependencies for pytorch: mkl >=2018, cudatoolkit >=9.0,<9.1, blas * mkl, cudatoolkit >=10.0,<10.1, cudatoolkit >=9.2,<9.3, blas * openblas, cudnn 7.0.*, cudatoolkit 9.*
Did you mean one of these?
pytorch, pytorch-gpu, pytorch-cpu
Did you mean one of these?
cudatoolkit
You can search for this package on anaconda.org with
anaconda search -t conda cudatoolkit 9.*
(and similarly for the other packages)
Here are my installed packages:
backports 1.0 py34_0
backports.shutil-get-terminal-size 1.0.0 <pip>
decorator 4.0.11 py34_0
get_terminal_size 1.0.0 py34_0
ipython 4.2.0 py34_0
ipython-genutils 0.1.0 <pip>
ipython_genutils 0.1.0 py34_0
libgfortran 1.0 0
numpy 1.9.2 py34_0
openssl 1.0.2l 0
path.py 10.0 py34_0
pexpect 4.2.1 py34_0
pickleshare 0.7.4 py34_0
pip 9.0.1 py34_1
ptyprocess 0.5.1 py34_0
python 3.4.5 0
readline 6.2 2
scipy 0.16.0 np19py34_0
setuptools 27.2.0 py34_0
simplegeneric 0.8.1 py34_1
six 1.10.0 py34_0
sqlite 3.13.0 0
tk 8.5.18 0
traitlets 4.3.1 py34_0
wheel 0.29.0 py34_0
xz 5.2.3 0
zlib 1.2.11 0
What should I do? Thank you!
Pytorch's vision package (aka torchvision) was developed post-Python 3.4, and so only has versions supporting Python 2.7, 3.5-7. Please create a new environment with a later Python version. Note it is always better to include the packages you care about in the creation of the environment, e.g.,
conda create -n env_name -c pytorch torchvision
and Conda will figure the rest out. If you need to have a specific version of Python, you can include that as well (e.g., python=3.6).
Please try the following steps.It worked fine for me.
source activate env_name
conda install -c pytorch pytorch
open python shell
import torch
I can't give you a definite answer cause you didn't provided the info about the Python version, platform you're using.
Go to the official website for Pytorch, choose a installation method according to your platform, Python version and whether you need CUDA.

How to change Python version in Anaconda, install Numpy and sklearn 0.17?

I'm new to machine learning. I literally have no idea what I'm doing but I need tools to understand how machine learning works.
I just download Anaconda Python from here. I saw that the version I downloaded is 3.7 but I need a 3.5.
I don't really understand how to install Numpy 1.10 as well as sklearn 0.17
Can you please guide me how to install these?
The best way to do this is by using a custom conda environment. You can do this by either of the following:
install the full version of Anaconda (the current version with Python 3.7)
install Miniconda for a much smaller download
Then open Anaconda Prompt in the Windows start menu. Then do:
conda create -n customenvname python=3.5 numpy=1.10 scikit-learn=0.17
Follow the prompts.
To activate the new environment and get off and running, just do conda activate customenvname. You are now in a Python 3.5 environment with all the dependencies you need:
(base) C:\Users\user>conda activate customenvname
(customenvname) C:\Users\user>python --version
Python 3.5.6 :: Anaconda, Inc.
(customenvname) C:\Users\user>conda list
# packages in environment at C:\Users\user\Miniconda3\envs\customenvname:
#
# Name Version Build Channel
blas 1.0 mkl
certifi 2018.8.24 py35_1
mkl 11.3.3 1
numpy 1.10.4 py35_2
pip 10.0.1 py35_0
python 3.5.6 he025d50_0
scikit-learn 0.17.1 np110py35_1
scipy 0.17.1 np110py35_1
setuptools 40.2.0 py35_0
vc 14.1 h0510ff6_4
vs2015_runtime 14.15.26706 h3a45250_0
wheel 0.31.1 py35_0
wincertstore 0.2 py35hfebbdb8_0
NOTE: the mkl package is an optimization of some of the most used scientific computing libraries maintained by anaconda.

Resources