<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Mad-Solves]]></title><description><![CDATA[Mad-Solves]]></description><link>https://mad-solve.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sat, 05 Sep 2026 11:14:38 GMT</lastBuildDate><atom:link href="https://mad-solve.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[How to Import from a Python File in Google Drive to a Colab Notebook (in 4 Simple Steps)]]></title><description><![CDATA[Step 1: Mount Google Drive
from google.colab import drive
drive.mount('/content/drive')


This connects your Google Drive to the Colab environment.


Step 2: Verify the File Path
import os  # Imports Python's built-in os module for interacting with t...]]></description><link>https://mad-solve.hashnode.dev/how-to-import-from-a-python-file-in-google-drive-to-a-colab-notebook-in-4-simple-steps</link><guid isPermaLink="true">https://mad-solve.hashnode.dev/how-to-import-from-a-python-file-in-google-drive-to-a-colab-notebook-in-4-simple-steps</guid><category><![CDATA[mount google drive]]></category><category><![CDATA[Google Drive]]></category><category><![CDATA[Google Colab]]></category><dc:creator><![CDATA[Madara Wimalarathna]]></dc:creator><pubDate>Fri, 04 Jul 2025 14:11:28 GMT</pubDate><content:encoded><![CDATA[<h4 id="heading-step-1-mount-google-drive"><strong>Step 1: Mount Google Drive</strong></h4>
<pre><code class="lang-python"><span class="hljs-keyword">from</span> google.colab <span class="hljs-keyword">import</span> drive
drive.mount(<span class="hljs-string">'/content/drive'</span>)
</code></pre>
<blockquote>
<p>This connects your Google Drive to the Colab environment.</p>
</blockquote>
<hr />
<h4 id="heading-step-2-verify-the-file-path"><strong>Step 2: Verify the File Path</strong></h4>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> os  <span class="hljs-comment"># Imports Python's built-in os module for interacting with the file system</span>

<span class="hljs-comment"># List files inside the target folder</span>
os.listdir(<span class="hljs-string">"/content/drive/MyDrive/Colab_Notebooks"</span>)
</code></pre>
<blockquote>
<p>This helps confirm your <code>.py</code> file is located where you expect it to be. Make sure the filename appears in the output.</p>
</blockquote>
<hr />
<h4 id="heading-step-3-add-your-modules-folder-to-python-path"><strong>Step 3: Add Your Module's Folder to Python Path</strong></h4>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> sys
sys.path.append(<span class="hljs-string">'/content/drive/MyDrive/Colab_Notebooks'</span>)
</code></pre>
<blockquote>
<p>Adjust the path if your <code>.py</code> file is in a subfolder.</p>
</blockquote>
<hr />
<h4 id="heading-step-4-import-your-python-file-as-a-module"><strong>Step 4: Import Your Python File as a Module</strong></h4>
<pre><code class="lang-python"><span class="hljs-keyword">import</span> your_file_name  <span class="hljs-comment"># Do not include the `.py` extension</span>
</code></pre>
<blockquote>
<p>Now you can use:</p>
</blockquote>
<pre><code class="lang-python">your_file_name.your_function()
</code></pre>
<p>Congratulations…!!! :)</p>
]]></content:encoded></item></channel></rss>