简体   繁体   中英

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 ?

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/')

The -p argument when executing the installer is not used correctly. It should be:

bash ./Anaconda3-5.1.0-Linux-x86_64.sh -b -f -p conda3

instead of:

bash ./Anaconda3-5.1.0-Linux-x86_64.sh -b -f -p=conda3

You're actually installing conda in the folder =conda3 . Since the output you see is the message:

ERROR: The install method you used for conda--probably either `pip install conda`...

you probably have another install of conda (done with pip) in your system python.

EDIT following the OP's edit

First of all, I would like to say that it is not good practice to entirely change the question with an edit. Please ask a new question if you encounter new problems !!
I think you do not understand how conda works. It creates virtual environments which you can activate or deactivate. Your question:

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?

makes no sense since installing a package into global python (not in a virtual environments) has nothing to do with conda. Furthermore you state:

It requires conda-forge to be build.

conda-forge is a channel in conda. It is only a repository where packages are located and available for download. You don't "install" conda-forge, you put it as a channel (option -c) when you want to download a tool from this repository.

Having said this, here is how I would solve the problem. After having installed Anaconda (btw, you didn't change the code concerning the -p option like I describe above), you create a virtual environment that will host all the tools you need:

conda create -n myenv -c conda-forge -c dlr-sc -c pythonocc -c oce pythonocc-core

then you activate your environment to access the tools you just installed

source activate myenv

Now, you should have access to everything you need.

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

And it worked for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM