<?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 Not able to run spark context by running python file in a cell using %sh in Get Started Discussions</title>
    <link>https://community.databricks.com/t5/get-started-discussions/not-able-to-run-spark-context-by-running-python-file-in-a-cell/m-p/37318#M446</link>
    <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;I am trying to get spark context by running SparkSession builder command in a .py file and when i try to run it directl it works but if i got to a notebook and in a cell if i use %sh command to run python "myfilename" it gives an error that i am trying to create a new session. How to solve this?&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="deficiant_codge_1-1689000063074.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/2821i021E0988ACA475AB/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="deficiant_codge_1-1689000063074.png" alt="deficiant_codge_1-1689000063074.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="deficiant_codge_2-1689000103143.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/2822i7208C3018F73AA51/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="deficiant_codge_2-1689000103143.png" alt="deficiant_codge_2-1689000103143.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Mon, 10 Jul 2023 14:45:54 GMT</pubDate>
    <dc:creator>deficiant_codge</dc:creator>
    <dc:date>2023-07-10T14:45:54Z</dc:date>
    <item>
      <title>Not able to run spark context by running python file in a cell using %sh</title>
      <link>https://community.databricks.com/t5/get-started-discussions/not-able-to-run-spark-context-by-running-python-file-in-a-cell/m-p/37318#M446</link>
      <description>&lt;P&gt;Hi Everyone,&lt;/P&gt;&lt;P&gt;I am trying to get spark context by running SparkSession builder command in a .py file and when i try to run it directl it works but if i got to a notebook and in a cell if i use %sh command to run python "myfilename" it gives an error that i am trying to create a new session. How to solve this?&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="deficiant_codge_1-1689000063074.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/2821i021E0988ACA475AB/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="deficiant_codge_1-1689000063074.png" alt="deficiant_codge_1-1689000063074.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="deficiant_codge_2-1689000103143.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/2822i7208C3018F73AA51/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="deficiant_codge_2-1689000103143.png" alt="deficiant_codge_2-1689000103143.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 14:45:54 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/not-able-to-run-spark-context-by-running-python-file-in-a-cell/m-p/37318#M446</guid>
      <dc:creator>deficiant_codge</dc:creator>
      <dc:date>2023-07-10T14:45:54Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to run spark context by running python file in a cell using %sh</title>
      <link>https://community.databricks.com/t5/get-started-discussions/not-able-to-run-spark-context-by-running-python-file-in-a-cell/m-p/37320#M447</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/50331"&gt;@deficiant_codge&lt;/a&gt;, Databricks already provide variables for sparksession and sparkcontext.&lt;/P&gt;&lt;P&gt;Use &lt;STRONG&gt;spark&lt;/STRONG&gt; for sparksession and&amp;nbsp;&lt;STRONG&gt;sc&amp;nbsp;&lt;/STRONG&gt;for sparkcontext.&lt;BR /&gt;I think this would help you.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 14:53:08 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/not-able-to-run-spark-context-by-running-python-file-in-a-cell/m-p/37320#M447</guid>
      <dc:creator>Hemant</dc:creator>
      <dc:date>2023-07-10T14:53:08Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to run spark context by running python file in a cell using %sh</title>
      <link>https://community.databricks.com/t5/get-started-discussions/not-able-to-run-spark-context-by-running-python-file-in-a-cell/m-p/37323#M448</link>
      <description>&lt;P&gt;Actually i have some use case in which i have to mandatorily run the python file using %sh and in that i can't able to access those variables. I am aware of these variables but the problem is they just don't work.&lt;BR /&gt;see the below images:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="deficiant_codge_0-1689001870121.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/2823i7787168E94403110/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="deficiant_codge_0-1689001870121.png" alt="deficiant_codge_0-1689001870121.png" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="deficiant_codge_1-1689001889304.png" style="width: 400px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/2824i6C3CD0C8703F15C4/image-size/medium/is-moderation-mode/true?v=v2&amp;amp;px=400" role="button" title="deficiant_codge_1-1689001889304.png" alt="deficiant_codge_1-1689001889304.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 15:11:38 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/not-able-to-run-spark-context-by-running-python-file-in-a-cell/m-p/37323#M448</guid>
      <dc:creator>deficiant_codge</dc:creator>
      <dc:date>2023-07-10T15:11:38Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to run spark context by running python file in a cell using %sh</title>
      <link>https://community.databricks.com/t5/get-started-discussions/not-able-to-run-spark-context-by-running-python-file-in-a-cell/m-p/37324#M449</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/50331"&gt;@deficiant_codge&lt;/a&gt;&amp;nbsp; Can you try with below:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;_spark_session&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;SparkSession&lt;/SPAN&gt;&lt;SPAN&gt; \&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; .&lt;/SPAN&gt;&lt;SPAN&gt;Builder&lt;/SPAN&gt;&lt;SPAN&gt;() \&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; .&lt;/SPAN&gt;&lt;SPAN&gt;appName&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"myapp"&lt;/SPAN&gt;&lt;SPAN&gt;) \&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; .&lt;/SPAN&gt;&lt;SPAN&gt;getOrCreate&lt;/SPAN&gt;&lt;SPAN&gt;()&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 10 Jul 2023 15:42:09 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/not-able-to-run-spark-context-by-running-python-file-in-a-cell/m-p/37324#M449</guid>
      <dc:creator>Hemant</dc:creator>
      <dc:date>2023-07-10T15:42:09Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to run spark context by running python file in a cell using %sh</title>
      <link>https://community.databricks.com/t5/get-started-discussions/not-able-to-run-spark-context-by-running-python-file-in-a-cell/m-p/37325#M450</link>
      <description>&lt;P&gt;I tried it also attached the image attached with the post, but it didn't worked&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 15:44:29 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/not-able-to-run-spark-context-by-running-python-file-in-a-cell/m-p/37325#M450</guid>
      <dc:creator>deficiant_codge</dc:creator>
      <dc:date>2023-07-10T15:44:29Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to run spark context by running python file in a cell using %sh</title>
      <link>https://community.databricks.com/t5/get-started-discussions/not-able-to-run-spark-context-by-running-python-file-in-a-cell/m-p/37326#M451</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/50331"&gt;@deficiant_codge&lt;/a&gt;&amp;nbsp; there is minor difference can you try it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 15:45:55 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/not-able-to-run-spark-context-by-running-python-file-in-a-cell/m-p/37326#M451</guid>
      <dc:creator>Hemant</dc:creator>
      <dc:date>2023-07-10T15:45:55Z</dc:date>
    </item>
    <item>
      <title>Re: Not able to run spark context by running python file in a cell using %sh</title>
      <link>https://community.databricks.com/t5/get-started-discussions/not-able-to-run-spark-context-by-running-python-file-in-a-cell/m-p/37332#M452</link>
      <description>&lt;P&gt;No Success &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 17:04:58 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/not-able-to-run-spark-context-by-running-python-file-in-a-cell/m-p/37332#M452</guid>
      <dc:creator>deficiant_codge</dc:creator>
      <dc:date>2023-07-10T17:04:58Z</dc:date>
    </item>
  </channel>
</rss>

