![見出し画像](https://assets.st-note.com/production/uploads/images/80457195/rectangle_large_type_2_44e0f9ea5436f88b036bae1cb298bf26.png?width=1200)
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の書き方が間違っててただ直しただけでは正しいのが反映されません。
再度
![](https://assets.st-note.com/img/1654937986449-3myGSufeFW.png)
ランタイムを再起動してください。
この記事が気に入ったらサポートをしてみませんか?