A simple Python command on Databricks
selection = input("Enter value")
doesn't create a window box to enter the value. Searching reasons on the User Interface or other?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
โ06-21-2023 05:54 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
โ06-21-2023 11:28 AM
Hi, Chico:
In Databricks notebooks, input() function calls won't work as you might expect from running Python in other environments. Because Databricks notebooks are using Spark. They're not intended to interact with users in real-time, such as taking keyboard inputs.
There is alternative way: Databricks has a feature called "widgets". Widgets are interactive HTML forms that can be embedded within Databricks notebooks. Here is the example:
dbutils.widgets.text("inputs", '{"name":"Monica, "company":"Databricks"}')
inputs = dbutils.widgets.get("inputs")
Reference doc: https://docs.databricks.com/dev-tools/databricks-utils.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
โ06-22-2023 12:29 AM
Hello
I should nave clarified: this a Pyspark environnment not just a Python one.
The issue relies in the cluster settings as taking an other one provides the expected outcome. What is sspecific in my initial cluter SFC ?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
โ06-21-2023 10:05 PM
Hi @stephane cochetโ
Thank you for posting your question in our community! We are happy to assist you.
To help us provide you with the most accurate information, could you please take a moment to review the responses and select the one that best answers your question?
This will also help other community members who may have similar questions in the future. Thank you for your participation and let us know if you need any further assistance!