简体   繁体   English

如何在colab.research上通过conda构建库?

[英]How to build libraries via conda on colab.research?

So I want to use python-occ library. 所以我想使用python-occ库。 It requires conda-forge to be build. 它需要构建conda-forge 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. 然而它会在condas python中安装一个包。 How to make oit install package into global python or use its python\\libs folder for cels interpritation? 如何将oit安装包导入全局python或使用其python \\ libs文件夹进行cels interpritation?

So what one must do to build/install stuff with conda in colab ? 那么,一个必须做的建立/安装带的东西condacolab

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. 执行安装程序时的-p参数未正确使用。 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 . 你实际上是在folder =conda3安装=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. 你可能在你的系统python中有另一个conda安装(用pip完成)。

EDIT following the OP's edit OP编辑后编辑

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. 然而它会在condas python中安装一个包。 How to make oit install package into global python or use its python\\libs folder for cels interpritation? 如何将oit安装包导入全局python或使用其python \\ libs文件夹进行cels interpritation?

makes no sense since installing a package into global python (not in a virtual environments) has nothing to do with conda. 因为将包安装到全局python(不是在虚拟环境中)与conda无关,所以没有任何意义。 Furthermore you state: 此外,你说:

It requires conda-forge to be build. 它需要构建conda-forge。

conda-forge is a channel in conda. conda-forgeconda-forge一个频道。 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. 如果要从此存储库下载工具,则不要“安装”conda-forge,将其设置为通道(选项-c)。

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: 在安装了Anaconda之后(顺便说一下,你没有像我上面描述的那样改变有关-p选项的代码),你创建了一个虚拟环境来托管你需要的所有工具:

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. 我曾经需要一个只能通过Conda获得的图书馆。 My solution is that 我的解决方案是

And it worked for me. 它对我有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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