見出し画像

Google Colaboratoryで[.py]のファイルをインポートする方法【備忘禄】

まずはファイル構成

 My Drive/
  └ my_file 
   ├ Fuel_economy.ipynb
   └ my_modules/
      └ modules.py

そしてマウント

from google.colab import drive
drive.mount('/content/drive/')

import sys
sys.path.append('/content/drive/My Drive/my_file/my_modules')


mport modules

これで.py を使うことが出来るが、、、、

NOTE: If your import is failing due to a missing package, you can manually install dependencies using either !pip or !apt. To view examples of installing some common dependencies, click the "Open Examples" button below.

これが出た場合、なにか.pyの書き方が間違っててただ直しただけでは正しいのが反映されません。

再度


ランタイムを再起動してください。

この記事が気に入ったらサポートをしてみませんか?