【发布时间】:2020-01-15 01:28:06
【问题描述】:
我需要在 Google colab 中使用 cfitsio 库编译一些 c 程序,在我的 mac 中我可以执行以下操作:
1. download the files and unzip it http://heasarc.gsfc.nasa.gov/fitsio/fitsio.html
2.
sudo -H ./configure --enable-sse2 --prefix=/usr/local --enable-reentrant
sudo -H make
sudo -H make install
但是,我不允许在 google colab 中使用 sudo(当然这是必需的行为)
当我尝试在没有 sudo 的情况下安装模块时,它给了我权限错误。
第一步:挂载谷歌驱动器
import sys
ENV_COLAB = 'google.colab' in sys.modules
if ENV_COLAB:
### mount google drive
from google.colab import drive
drive.mount('/content/drive')
step2: cd 到模块的路径
%%bash
cd "drive/My Drive/Colab Notebooks/Research/cfitsio-3.47"
./configure --user --enable-sse2 --enable-reentrant
# step3: module installation fails
bash: ./configure: /bin/sh: bad interpreter: Permission denied
step4: 问:如何安装模块?
如何在Google colab中安装CFITSIO模块并编译?
【问题讨论】:
-
顺便说一句,即使在您的 Mac 中,您也不应该在编译代码时使用
sudo。这是危险且不必要的(如果出于某种原因看起来有必要,那么您的系统上配置错误)。
标签: python bash google-colaboratory fits