簡體   English   中英

如何在 Google Colaboratory 中安裝第三方模塊

[英]How to install a third party module in Google Colaboratory

我需要在 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 的情況下安裝模塊時,它給了我權限錯誤。

步驟1:掛載谷歌驅動器

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 模塊並編譯它?

不需要sudo 在 Colab 上,您已經以 root 身份運行。

這是一個完整的示例筆記本:

https://colab.research.google.com/drive/1RqtDwzhL8vWEJ-3ruGUGo-QckWr6gHUJ

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM