I was able to install packages in google colab with pip, using:
!pip install....
but i am not able to install any package from conda-forge. I tried:
!conda install -c conda-forge cartopy
To install conda, a library has been created specifically for Google Colab, conda-colab, and fortunately for us it is very easy to use ! You just have to install it with the pip command, then install conda with the condacolab. install() function. The code should return something like : conda 4.9.
Unfortunately, Conda is not available by default on Google Colab and getting Conda installed and working properly within Google Colab's default Python environment is a bit of a chore.
In general, this is a way to install a package in conda from Colab:
!wget https://repo.continuum.io/miniconda/Miniconda3-4.5.4-Linux-x86_64.sh
!bash Miniconda3-4.5.4-Linux-x86_64.sh -bfp /usr/local
# Append path to be able to run packages installed with conda
import sys
sys.path.append('/usr/local/lib/python3.6/site-packages')
# Install packages from Anaconda
!conda install -y [package]
This works for packages like -c pslmodels taxcalc
(notebook).
However, cartopy
is a complicated package that's creating problems here, I think because the above requires an older version of conda
*, which is no longer compatible with cartopy
. Here's a Colab notebook that uses this version and fails because cartopy
requires the shapefile
package, and this is one that uses the latest version of conda and isn't recognized upon import
.
* For example, here are versions of the taxcalc
notebook that install the latest installer and run conda update conda
before installing taxcalc
; import taxcalc
isn't recognized in either case. See this GitHub issue.
One way to get it is to just Unzip the conda
package to a directory directly.
Get you required conda
package from anaconda.org
, download it.
Decompress them and copy them into the library path
Here's an example to install faiss
from anaconda using this way.
https://gist.github.com/korakot/d0a49d7280bd3fb856ae6517bfe8da7a
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With