我能够使用 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 installer和 run conda update conda
安装前 taxcalc
; import taxcalc
在任何一种情况下都无法识别。见 this GitHub issue .
关于python - 如何将 conda 包导入 google colab?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53000670/