<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to import local python file in notebook? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30191#M32074</link>
    <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;for example I have one.py and two.py in databricks and I want to use one of the module from one.py in two.py. Usually I do this in my local machine by import statement like below&lt;/P&gt;
&lt;P&gt;&lt;B&gt;&lt;/B&gt;&lt;B&gt;two.py&lt;/B&gt;&lt;B&gt;&lt;/B&gt;__&lt;/P&gt;
&lt;P&gt;from one import module1&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;How to do this in databricks???&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 04 Sep 2015 07:18:32 GMT</pubDate>
    <dc:creator>jsaddam28</dc:creator>
    <dc:date>2015-09-04T07:18:32Z</dc:date>
    <item>
      <title>How to import local python file in notebook?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30191#M32074</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;for example I have one.py and two.py in databricks and I want to use one of the module from one.py in two.py. Usually I do this in my local machine by import statement like below&lt;/P&gt;
&lt;P&gt;&lt;B&gt;&lt;/B&gt;&lt;B&gt;two.py&lt;/B&gt;&lt;B&gt;&lt;/B&gt;__&lt;/P&gt;
&lt;P&gt;from one import module1&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;.&lt;/P&gt;
&lt;P&gt;How to do this in databricks???&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Sep 2015 07:18:32 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30191#M32074</guid>
      <dc:creator>jsaddam28</dc:creator>
      <dc:date>2015-09-04T07:18:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to import local python file in notebook?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30192#M32075</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Just do a %run command of the other notebook which will import all the functions there.&lt;/P&gt;
&lt;P&gt;%run your_folder/run2.py&lt;/P&gt;
&lt;P&gt;-Vida&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Sep 2015 16:24:21 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30192#M32075</guid>
      <dc:creator>vida</dc:creator>
      <dc:date>2015-09-04T16:24:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to import local python file in notebook?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30193#M32076</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Hi Vida,&lt;/P&gt;
&lt;P&gt;I have the same problem, and I followed your solution but I get the error that the file cannot be found. I tried with and without full path when the run2.py is in the same folder of the notebook&lt;/P&gt;
&lt;P&gt;Stacktrace: /Users/username/Test NB: python&lt;/P&gt;
&lt;P&gt;Thanks for your assistance&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2015 16:23:58 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30193#M32076</guid>
      <dc:creator>JavierOrozco</dc:creator>
      <dc:date>2015-09-11T16:23:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to import local python file in notebook?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30194#M32077</link>
      <description>&lt;P&gt;&lt;/P&gt; 
&lt;P&gt;Hi,&lt;/P&gt; 
&lt;P&gt;You need the full path - we don't support relative paths yet. I can do the following:&lt;/P&gt; 
&lt;P&gt;%run "/Users/XXXXXXX@databricks.com/InnerNotebook"&lt;/P&gt; 
&lt;P&gt;Please make sure you copy the notebook name correctly without any spaces, etc.&lt;/P&gt; 
&lt;P&gt;-Vida&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2015 17:27:51 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30194#M32077</guid>
      <dc:creator>vida</dc:creator>
      <dc:date>2015-09-11T17:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to import local python file in notebook?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30195#M32078</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;This the exact copy of the code&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;%run '/Users/admin/s3_handling_poc.py'
Notebook not found: /Users/admin/s3_handling_poc.py
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Whereas with a Notebook it does work:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;%run /Users/admin/test2
Command took 0.18s
Hello World&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2015 19:08:16 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30195#M32078</guid>
      <dc:creator>JavierOrozco</dc:creator>
      <dc:date>2015-09-11T19:08:16Z</dc:date>
    </item>
    <item>
      <title>Re: How to import local python file in notebook?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30196#M32079</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Can you try without the ".py" at the end?&lt;/P&gt;
&lt;P&gt;What do you mean by with a notebook it does work?&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2015 19:09:35 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30196#M32079</guid>
      <dc:creator>vida</dc:creator>
      <dc:date>2015-09-11T19:09:35Z</dc:date>
    </item>
    <item>
      <title>Re: How to import local python file in notebook?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30197#M32080</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;I doesn't seem to work either, I created a "Hello World" inside a python script. If I run it with ".py" shows same error, but without ".py" looks executing but never ends until I cancel it.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2015 19:17:04 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30197#M32080</guid>
      <dc:creator>JavierOrozco</dc:creator>
      <dc:date>2015-09-11T19:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to import local python file in notebook?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30198#M32081</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Sorry - I'm confused - is your file - s3_handling_poc.py uploaded to Databricks?&lt;/P&gt;
&lt;P&gt;%run is for running one notebook within another Databricks notebook.&lt;/P&gt;
&lt;P&gt;To get local Python code into Databricks - you'll need to either import your python file as a Databricks Notebook. Or you can create an egg from your python code and upload that as a library. If it's a single python file - importing it as a Databricks notebook is going to be the easier route. &lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2015 19:20:56 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30198#M32081</guid>
      <dc:creator>vida</dc:creator>
      <dc:date>2015-09-11T19:20:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to import local python file in notebook?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30199#M32082</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;yes it is python code, I let it run and it managed to finish. &lt;/P&gt;
&lt;P&gt;I was following the initial instruction of how to import third party python modules. The instruction was to run them. However the same code runs faster within a notebook. The problem is how do I use my own existing python code into new databricks python notebooks. Do I have to embed all of them into a notebook?&lt;/P&gt;%run "/Users/admin/test_hello"
&lt;P&gt;&lt;/P&gt; 
&lt;P&gt;Command took 746.62s&lt;/P&gt; 
&lt;P&gt;HELLO WORLD FROM PYTHON &lt;/P&gt;</description>
      <pubDate>Fri, 11 Sep 2015 20:36:39 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30199#M32082</guid>
      <dc:creator>JavierOrozco</dc:creator>
      <dc:date>2015-09-11T20:36:39Z</dc:date>
    </item>
    <item>
      <title>Re: How to import local python file in notebook?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30200#M32083</link>
      <description>&lt;P&gt;@javier.orozco @realeuesit.com, did you ever get clarity or resolution to this problem, its as if dies with your last statement. The last two sentences of your comment sum the issue very nicely. &lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2016 19:37:48 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30200#M32083</guid>
      <dc:creator>PaulAgnew</dc:creator>
      <dc:date>2016-03-02T19:37:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to import local python file in notebook?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30201#M32084</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;@vida, how to run a notebook that is mounted with dbfs?&lt;/P&gt;
&lt;P&gt;%run 'dbfs:/mnt/&amp;lt;&amp;lt;pathtopyfile&amp;gt;&amp;gt;' keeps reporting Notebook not found. Tried with and without dbfs and same error.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Apr 2016 21:46:59 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30201#M32084</guid>
      <dc:creator>dchokkadi1_5588</dc:creator>
      <dc:date>2016-04-11T21:46:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to import local python file in notebook?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30202#M32085</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;@Deepak Chokkadi %run doesn't take a dbfs path - it takes the path to the notebook from the workspace.&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Apr 2016 22:15:57 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30202#M32085</guid>
      <dc:creator>vida</dc:creator>
      <dc:date>2016-04-11T22:15:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to import local python file in notebook?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30203#M32086</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Thanks @Vida Ha! Any other solution to execute a notebook from a mounted S3 path?&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 11 Apr 2016 22:28:54 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30203#M32086</guid>
      <dc:creator>dchokkadi1_5588</dc:creator>
      <dc:date>2016-04-11T22:28:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to import local python file in notebook?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30204#M32087</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Replying here instead of raising a new question.&lt;/P&gt;
&lt;P&gt;%run seems to be working OK, but what it does is to run the whole file which means that all the variables/functions become global. In this case the module cannot be used as an object "module.function" etc... &lt;/P&gt;
&lt;P&gt;What would be a workaround to do that? I guess re-writing the module as a class could work? This just doesn't "feel" right, writing a class where it should just be a module.&lt;/P&gt;
&lt;P&gt;Creating an egg has also been suggested, but again this would result in a package/library that cannot be easily edited.&lt;/P&gt;
&lt;P&gt;Any thoughts?&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Apr 2018 09:12:32 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30204#M32087</guid>
      <dc:creator>jurmu</dc:creator>
      <dc:date>2018-04-13T09:12:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to import local python file in notebook?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30205#M32088</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt; I have the exact same question. Databricks seems nice for some initial exploration / playing around but once it goes into professionalization being able to only use notebooks sets severe limits...&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 19 Feb 2019 15:31:44 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30205#M32088</guid>
      <dc:creator>ThomasKastl</dc:creator>
      <dc:date>2019-02-19T15:31:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to import local python file in notebook?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30206#M32089</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Is it possible to import a particular function using %run statement instead of running the whole notebook? &lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 03 May 2019 07:13:53 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30206#M32089</guid>
      <dc:creator>amanpreetkaur</dc:creator>
      <dc:date>2019-05-03T07:13:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to import local python file in notebook?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30207#M32090</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Databricks is a very rigid environment. They don't promote modularizing code. I don't understand why they disable / dissuade use of such basic concepts which are so generic to all programming languages.&lt;/P&gt;
&lt;P&gt;Even after so many years this is still a problem &lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 14:55:01 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30207#M32090</guid>
      <dc:creator>Dipan</dc:creator>
      <dc:date>2019-07-18T14:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to import local python file in notebook?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30208#M32091</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;The way to solve this problem is to add the path of your code to the system, then proceed to import modules selectively or all modules in a file.&lt;/P&gt;
&lt;P&gt;You can download an example notebook from here &lt;A href="https://github.com/javierorozco/databricks_import_python_module" target="test_blank"&gt;https://github.com/javierorozco/databricks_import_python_module&lt;/A&gt;&lt;/P&gt;import sys
&lt;P&gt;&lt;/P&gt; 
&lt;P&gt;// Add the path to system, local or mounted S3 bucket, e.g. /dbfs/mnt/&amp;lt;path_to_bucket&amp;gt; sys.path.append('/databricks/driver/') sys.path.append('/databricks/driver/databricks_import_python_module/') sys.path.append('/databricks/driver/databricks_import_python_module/test.py')  &lt;/P&gt;</description>
      <pubDate>Thu, 18 Jul 2019 22:18:38 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30208#M32091</guid>
      <dc:creator>JavierOrozco</dc:creator>
      <dc:date>2019-07-18T22:18:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to import local python file in notebook?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30209#M32092</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://users/333/javierorozco.html" target="_blank"&gt;@javier.orozco@realeuesit.com&lt;/A&gt;, I was able to work with the file created in your repo (test.py) but my with my own modules I am getting error. Anything I am missing?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0693f000007Oro5AAC"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/2543i34C69EC8907A753C/image-size/large?v=v2&amp;amp;px=999" role="button" title="0693f000007Oro5AAC" alt="0693f000007Oro5AAC" /&gt;&lt;/span&gt;&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Dec 2019 04:49:02 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30209#M32092</guid>
      <dc:creator>shantanuneema</dc:creator>
      <dc:date>2019-12-25T04:49:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to import local python file in notebook?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30210#M32093</link>
      <description>&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Tried this. %run runs the py file, print a print statement in external file. But what I want is to get a variable from external file and use it in current notebook. That doesn't work. (added some print statements below, the variable in file is called pseg_main)&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper" image-alt="0693f000007OrnwAAC"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/2535iD83BF1A548B9E5B8/image-size/large?v=v2&amp;amp;px=999" role="button" title="0693f000007OrnwAAC" alt="0693f000007OrnwAAC" /&gt;&lt;/span&gt;&lt;/P&gt; 
&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Dec 2019 11:20:01 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-to-import-local-python-file-in-notebook/m-p/30210#M32093</guid>
      <dc:creator>awaiskaleem</dc:creator>
      <dc:date>2019-12-30T11:20:01Z</dc:date>
    </item>
  </channel>
</rss>

