如何将conda包导入Google colab? [英] how to import conda packages into google colab?

查看:786
本文介绍了如何将conda包导入Google colab?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I was able to install packages in google colab with pip, using:

!pip install....

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

but i am not able to install any package from conda-forge. I tried:

!conda install -c conda-forge cartopy


推荐答案

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

In general, this is a way to install a package in conda from Colab:

!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]

这适用于 -c pslmodels taxcalc 笔记本)。

但是, cartopy 是一个复杂的程序包,在这里产生了问题,我想是因为上面的程序要求使用 conda *,它不再与 cartopy 兼容。这是一个 Colab笔记本,它使用此版本,但由于 cartopy而失败需要 shapefile 软件包,并且这是,它使用最新版本的conda,在导入时无法识别。

However, cartopy is a complicated package that's creating problems here, I think because the above requires an older version of conda*, which is no longer compatible with cartopy. Here's a Colab notebook that uses this version and fails because cartopy requires the shapefile package, and this is one that uses the latest version of conda and isn't recognized upon import.

*例如,下面是taxcalc 笔记本的版本rel = nofollow noreferrer>安装最新的安装程序并运行 conda更新conda ,然后安装 taxcalc ;在两种情况下均无法识别进口税计算器。参见此GitHub问题

* For example, here are versions of the taxcalc notebook that install the latest installer and run conda update conda before installing taxcalc; import taxcalc isn't recognized in either case. See this GitHub issue.

这篇关于如何将conda包导入Google colab?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆