0

I'm new to Python and coding environment. A complete beginner. I've been working on my jupyter notebook recently on an EDA analysis. I've been running this statement for the past days on my Anaconda Prompt:

streamlit run file.py

Today, I did my usual thing but now I'm getting an error for my .py files: "Error: Streamlit requires raw Python (.py) files". When I got to my file I see this: the beginning of the file shows an error I've never seen before

I don't know what's going on and how to fix this. I went back to my Jupyter Notebook and redownloaded as a .py file but still getting the same error.

Please give me a detailed explanation. As I'm new, I want to understand the issue to its core. Might be an exaggeration but would love to learn more of my errors.

Thanks,

I don't know what to try. I looked at similar issues but don't quite understand what's going on.

  • Welcome to Stack Overflow. Please take the 2-minute [tour]. Moreover, open [Help] and read at least [ask]. Then, [edit] your question to provide a [mcve]. BTW, `#! /usr/bin/env python` looks like a [shebang line](https://docs.python.org/3.11/using/windows.html?highlight=shebang#shebang-lines). The second line looks like an encoding declaration: [`# coding: utf-8` is a Python 2 thing](https://stackoverflow.com/questions/4872007/)… – JosefZ Sep 02 '23 at 14:08
  • If deleting the second line or the first two lines doesn't work ... What is the extension on your file? Could it be that simple that it is looking for the `.py` extension? Does it indicate where it is hitting the error with it not being a pure Python file? You just show us the top. The way you converted from your notebook technically can cause problems. It doesn't convert special IPython/Jupyter things that appear in an `.ipynb` file. In fact for developing with Starlit it is best to just write `.py` files in a coding text editor and not be using Jupyter notebook files to write your code. – Wayne Sep 02 '23 at 14:39
  • @Wayne interesting, simply by deleting those 2 lines it worked. The extension is .py when I downloaded from Jupyter Notebook. The reason why I showed the top is cause that's the only thing I see for errors when I downloaded it as a .py extension, everything else looks how it should with all my codes. Thank you for the advice as well! – codewolf13 Sep 02 '23 at 17:19
  • About the deleting, I was just repeating what JosefZ was suggesting before suggesting other things. Glad the problem was that straightforward. I still sort of wonder if the shebang line being left would be fine because that is pretty standard. However, maybe the direction it was providing as to where to use Python from would clash with where Streamlit is running from and so it is sensitive to it. – Wayne Sep 02 '23 at 17:28
  • @JosefZ thank you for the advice! I will look into that! – codewolf13 Sep 02 '23 at 19:00

0 Answers0