Wednesday, October 14, 2020

Compare pip and conda installations


1. View all environments.

(base) C:\Users\aj>conda env list
# conda environments:
#
base                  *  D:\programfiles\Anaconda3
bert_aas                 D:\programfiles\Anaconda3\envs\bert_aas
e20200909                D:\programfiles\Anaconda3\envs\e20200909
...
tf                       D:\programfiles\Anaconda3\envs\tf 

2. View all Jupyter Kernels.

(base) C:\Users\aj>jupyter kernelspec list
Available kernels:
temp       C:\Users\aj\AppData\Roaming\jupyter\kernels\temp
tf         C:\Users\aj\AppData\Roaming\jupyter\kernels\tf
python3    D:\programfiles\Anaconda3\share\jupyter\kernels\python3
py38       C:\ProgramData\jupyter\kernels\py38

(base) C:\Users\aj> 

==========

3. A note about updating a package in Conda (from debugging instructions).

(base) C:\Users\aj>conda update ipykernel jupyter -c conda-forge

Updating ipykernel is constricted by

anaconda -> requires ipykernel==5.1.4=py37h39e3cac_0

If you are sure you want an update of your package either try `conda update --all` or install a specific version of the package you want using `conda install [pkg]=[version]`

done

==> WARNING: A newer version of conda exists.
current version: 4.8.4
latest version: 4.8.5

Please update conda by running

  $ conda update -n base -c defaults conda 

In this command, by '-n base' we mean 'base' is the name of the environment.
By '-c defaults', we mean download 'conda' from the 'defaults' channel.

Note: Following are three commonly used channels for downloading Python packages:

1. pkgs/main
2. defaults
3. conda-forge

==========

4. Installing a new Jupyter kernel. 

(e20200909) CMD>python -m ipykernel install --user --name e20200909 
Installed kernelspec e20200909 in C:\Users\aj\AppData\Roaming\jupyter\kernels\e20200909 

==========

5. Checking installation 
Differentiating between 'pip' and 'conda' installation. 

(e20200909) D:\ws\jupyter>pip freeze | findstr /C:"jupyter" /C:"jupyterlab" 
jupyter-client @ file:///tmp/build/80754af9/jupyter_client_1594826976318/work
jupyter-console @ file:///home/conda/feedstock_root/build_artifacts/jupyter_console_1598728807792/work
jupyter-core==4.6.3
jupyterlab==2.2.8
jupyterlab-pygments @ file:///home/conda/feedstock_root/build_artifacts/jupyterlab_pygments_1601375948261/work
jupyterlab-server @ file:///home/conda/feedstock_root/build_artifacts/jupyterlab_server_1593951277307/work 

(e20200909) C:\Users\aj>pip freeze | findstr /C:"transformers" /C:"tensorflow" /C:"torch" 
torch @ file:///C:/ci/pytorch_1596373105144/work
transformers==3.0.1 

Important Note: In the above two outputs, where we see a "@ file" based path in place of package version, that package has been installed via 'conda'. 

(e20200909) C:\Users\aj>python -c "import torch; print(torch.__version__);" 
1.6.0


View only Conda installations 
(e20200909) CMD>pip freeze | findstr /C:"file" 
argon2-cffi @ file:///D:/bld/argon2-cffi_1596630042503/work
attrs @ file:///home/conda/feedstock_root/build_artifacts/attrs_1599308529326/work
bleach @ file:///home/conda/feedstock_root/build_artifacts/bleach_1600454382015/work
cffi @ file:///C:/ci/cffi_1598352710791/work
... 

View only Pip installations 
(e20200909) CMD>pip freeze | findstr /v /C:"file" 
async-generator==1.10
backcall==0.2.0
bert-serving-client==1.10.0
bert-serving-server==1.10.0
certifi==2020.6.20
chardet==3.0.4
click==7.1.2
... 

(e20200909) CMD>pip list 
Package             Version
-------------------  -------------------
argon2-cffi          20.1.0
async-generator      1.10
attrs                20.2.0
backcall             0.2.0
bert-serving-client  1.10.0
bert-serving-server  1.10.0
bleach               3.2.1
certifi              2020.6.20
cffi                 1.14.2
chardet              3.0.4
click                7.1.2
... 

==========

6. Conda has more clarity about getting a good match between versions of already installed packages and the new packages that are to be installed:

(e20200909) C:\Users\Ashish Jain>conda install tensorflow -c conda-forge 
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.
Examining python=3.8:  50%|███████████████          | 1/2 [00:03<00:03,  3.41s/it]-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. 

==========

7. Getting all the available versions of a package in PyPI:

(base) CMD>pip install tensorflow== 
ERROR: Could not find a version that satisfies the requirement tensorflow== (from versions: 1.13.0rc1, 1.13.0rc2, 1.13.1, 1.13.2, 1.14.0rc0, 1.14.0rc1, 1.14.0, 1.15.0rc0, 1.15.0rc1, 1.15.0rc2, 1.15.0rc3, 1.15.0, 1.15.2, 1.15.3, 1.15.4, 2.0.0a0, 2.0.0b0, 2.0.0b1, 2.0.0rc0, 2.0.0rc1, 2.0.0rc2, 2.0.0, 2.0.1, 2.0.2, 2.0.3, 2.1.0rc0, 2.1.0rc1, 2.1.0rc2, 2.1.0, 2.1.1, 2.1.2, 2.2.0rc0, 2.2.0rc1, 2.2.0rc2, 2.2.0rc3, 2.2.0rc4, 2.2.0, 2.2.1, 2.3.0rc0, 2.3.0rc1, 2.3.0rc2, 2.3.0, 2.3.1)
ERROR: No matching distribution found for tensorflow== 

If Conda does not have a package in one of the mentioned channels such as 'conda-forge' or 'defaults', it raises the below exception:

ResolvePackageNotFound:
  - tensorflow=1.15.4 

==========

8. Checking TensorFlow 1.X installation:

(bert_env) CMD>conda list tensorflow 
# packages in environment at E:\programfiles\Anaconda3\envs\bert_env:
#
# Name                    Version                   Build  Channel
tensorflow                1.14.0               h1f41ff6_0    conda-forge
tensorflow-base           1.14.0           py37hc8dfbb8_0    conda-forge
tensorflow-estimator      1.14.0           py37h5ca1d4c_0    conda-forge 

(bert_env) CMD>python 
>>> import tensorflow as tf
>>> print(tf.__version__) 
2.3.0 
>>>       

~ ~ ~ ~ ~

(bert_env) CMD>pip freeze | find "tensorflow" 
tensorflow==2.3.0
tensorflow-estimator==2.3.0 

(bert_env) CMD>pip freeze | findstr "tensorflow" 
tensorflow==2.3.0
tensorflow-estimator==2.3.0 

(bert_env) CMD>python -c "import tensorflow as tf; print(tf.__version__)" 
2.3.0 

(bert_env) CMD>pip show tensorflow 
Name: tensorflow
Version: 2.3.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: packages@tensorflow.org
License: Apache 2.0
Location: c:\users\aj\appdata\roaming\python\python37\site-packages
Requires: wheel, astunparse, numpy, protobuf, wrapt, gast, six, tensorflow-estimator, scipy, grpcio, termcolor, tensorboard, opt-einsum, absl-py, keras-preprocessing, h5py, google-pasta
Required-by: 

==========


No comments:

Post a Comment