How to build libraries via conda on colab.research?

泄露秘密 提交于 2020-01-22 12:20:10

问题


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?


回答1:


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



回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/49202649/how-to-build-libraries-via-conda-on-colab-research

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!