Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build libraries via conda on colab.research?

So I want to use python-occ library. It requires conda-forge to be build. I try to install it in basic notebook

!wget -c https://repo.continuum.io/archive/Anaconda3-5.1.0-Linux-x86_64.sh
!chmod +x Anaconda3-5.1.0-Linux-x86_64.sh
!bash ./Anaconda3-5.1.0-Linux-x86_64.sh -b -f -p=conda3
!export PYTHONPATH=./conda3/lib/python
!export PATH=./conda3/bin/:$PATH
!conda install -y -c conda-forge -c dlr-sc -c pythonocc -c oce pythonocc-core

Yet it will install a package into condas python. How to make oit install package into global python or use its python\libs folder for cels interpritation?

So what one must do to build/install stuff with conda in colab?

like image 444
DuckQueen Avatar asked Mar 09 '18 21:03

DuckQueen


People also ask

Can I create conda environment in Google Colab?

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.

How do I use conda with Google Colab?

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.

Can I use Google colab in Anaconda?

We often use Google Colab because of the several benefits like pre-installed libraries, saved on the cloud, collaboration and free GPU and TPU, etc. Sometimes we need anaconda environment for our project. Today we will see how to set up anaconda environment in Google Colab.

Can you import libraries in Google Colab?

To import a library that's not in Colaboratory by default, you can use !pip install or ! apt-get install .


2 Answers

The following seems to work:

!wget -c https://repo.continuum.io/archive/Anaconda3-5.1.0-Linux-x86_64.sh
!chmod +x Anaconda3-5.1.0-Linux-x86_64.sh
!bash ./Anaconda3-5.1.0-Linux-x86_64.sh -b -f -p /usr/local
!conda install -y --prefix /usr/local -c <<<your wish>>>>

import sys
sys.path.append('/usr/local/lib/python3.6/site-packages/')
like image 155
Dmitry Chichkov Avatar answered Oct 05 '22 22:10

Dmitry Chichkov


I once needed a library that was available only through Conda too. My solution is that

  • !pip install all the requirements of that library
  • unzip(decompress) the conda file i.e. pythonocc-core-0.18.1-py36hdfe9f0f_110.tar.bz2 into the right directory.

And it worked for me.

like image 40
korakot Avatar answered Oct 06 '22 00:10

korakot