python - 如何将 conda 包导入 google colab?

标签 python conda google-colaboratory cartopy

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

!pip install....

但我无法从 conda-forge 安装任何软件包。我试过:
!conda install -c conda-forge cartopy

最佳答案

一般来说,这是一种从 Colab 在 conda 中安装包的方法:

!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 这样的包( notebook )。

然而,cartopy是一个复杂的包,在这里会产生问题,我认为因为上面需要旧版本的 conda *,不再兼容 cartopy .这是一个 Colab notebook使用此版本并失败,因为 cartopy需要 shapefile包,和 this is one使用最新版本的 conda 并且不被 import 识别.

* 例如,这里是 taxcalc 的版本笔记本install the latest installerrun conda update conda 安装前 taxcalc ; import taxcalc在任何一种情况下都无法识别。见 this GitHub issue .

关于python - 如何将 conda 包导入 google colab?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53000670/

相关文章:

python - time.sleep() 的替代方法

python - 用 scrapy 解决 reCAPTCHA

python - 此输出中的 conda 依赖冲突在哪里?我看不到他们。 :(

python - 无法在 google colab 中安装 textract

google-colaboratory - 如何在 google colab 中获取当前帐户名

python - 在 PyGTK/GObject 中使用枚举属性

python - matplotlib.patches.FancyArrow 表现不佳吗?

python - “conda install”命令中c标志的作用是什么

python - Conda 在使用 channel 时无法解析 requirements.yml

jupyter-notebook - 如何将 colab 深色主题引入 Jupyter Notebook