如何将conda包导入Google colab?

时间:2018-10-26 02:41:14

标签: python conda google-colaboratory cartopy

嗨,我能够使用pip在Google colab中安装软件包,

!pip install....

但是我无法从conda-forge安装任何软件包。我尝试过:

!conda install -c conda-forge cartopy

提前谢谢!

4 个答案:

答案 0 :(得分:1)

一种获取方法是直接将conda包解压缩到目录中。

  1. conda获取所需的anaconda.org软件包,然后将其下载。

  2. 解压缩它们并将其复制到库路径

以下是使用这种方式从anaconda安装faiss的示例。 https://gist.github.com/korakot/d0a49d7280bd3fb856ae6517bfe8da7a

答案 1 :(得分:0)

另一个选项(我没有尝试过)是连接到自定义运行时(在Jupyter看来是内核)。 https://research.google.com/colaboratory/local-runtimes.html

工作流程为:

  • 使用所需的东西+ jupyter_http_over_ws
  • 创建一个conda环境
  • 在计算机上启动笔记本,然后connect colab as described

这可能不是您要查找的内容,因为它确实需要本地安装(因此不再是零安装)。

答案 2 :(得分:0)

我对Cartopy使用解压缩方法。这是结果。

# get package then extract
!wget https://anaconda.org/conda-forge/cartopy/0.16.0/download/linux-64/cartopy-0.16.0-py36h81b52dc_2.tar.bz2
!tar xvjf cartopy-0.16.0-py36h81b52dc_2.tar.bz2
!cp -r lib/python3.6/site-packages/* /usr/local/lib/python3.6/dist-packages/
# install dependencies
!pip install shapely pyshp
!apt install libproj-dev libgeos-dev
# finally
import cartopy

答案 3 :(得分:0)

通常,这是一种从Colab在conda中安装软件包的方法:

Label

这适用于Option Explicit Public wrd As Word.Application Public doc As Word.Document Function RTF2HTMLviaWord(rtf As String) As String 'Open Tools --> References --> and check Microsoft Scripting Runtime Dim fso As New FileSystemObject Dim text As TextStream Dim temp As String temp = Environ("TEMP") If Len(rtf) > 1 Then Set text = fso.CreateTextFile(temp & "\RTF2HTML.rtf", True) text.Write rtf text.Close If wrd Is Nothing Then Set wrd = New Word.Application End If Set doc = wrd.Documents.Open(temp & "\RTF2HTML.rtf", False) doc.SaveAs temp & "\RTF2HTML.htm", wdFormatHTML doc.Close fso.DeleteFile temp & "\RTF2HTML.rtf" Set text = fso.OpenTextFile(temp & "\RTF2HTML.htm", ForReading, False) RTF2HTMLviaWord = text.ReadAll text.Close fso.DeleteFile temp & "\RTF2HTML.htm" Else RTF2HTMLviaWord = "" End If End Function notebook)之类的软件包。

但是,+ (GADAdSize)adaptiveAdSizeForWidth:(CGFloat)width orientation:(GADUBannerOrientation)orientation { switch (orientation) { case kGADUBannerOrientationCurrent: return GADCurrentOrientationAnchoredAdaptiveBannerAdSizeWithWidth(width); case kGADUBannerOrientationLandscape: return GADLandscapeAnchoredAdaptiveBannerAdSizeWithWidth(width); case kGADUBannerOrientationPortrait: return GADPortraitAnchoredAdaptiveBannerAdSizeWithWidth(width); } } 是一个复杂的程序包,在这里造成了问题,我认为是因为上面的程序需要一个较旧的calculator *版本,该版本不再与$customers兼容。这是一个使用此版本的Colab notebook,但由于foreach ($customers as $customer) { $customer->calculator = $this->calculator($request); } 需要使用$customer软件包而失败,而this is one使用的是最新版本的conda,并且在{{1 }}。

*例如,这是Model笔记本的版本,在安装!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] 之前分别为install the latest installerrun conda update conda;两种情况均无法识别-c pslmodels taxcalc。参见this GitHub issue