0

I am pretty new to app development so please help. I am getting the following error while trying to run the app from anaconda prompt

Error: Streamlit requires raw Python (.py) files, but the provided file has no extension.

I have already tried renaming the file with .py at the end but did not work. Also the .py file exists in the virtual environment folder for sure.

sarwat zabeen
  • 11
  • 1
  • 1
  • 1
    Hi! You can add more information regarding your problem, like the command that you ran and the current directory you are working on, so we can better help you. Thanks! – Vince Calo Feb 24 '22 at 04:26
  • 1
    Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Feb 24 '22 at 04:29

4 Answers4

1
  1. I suggest you go to your cmd prompt then use cd until you get into the right directory then use streamlit run main.py.

  2. Use anaconda then create an environment(You call it what ever you want I just called it streamlit).

  3. Do exactly what you in the first solution.

Tore
  • 3
  • 2
0

If you are running it with a full path I.E. "C:/Users/.../main.py" try CDing into the directory then running it from it's relative path.

You can do this by running streamlit run main.py

ATK
  • 36
  • 6
  • I was already cd-ing and then running the streamlit run command. However, for some strange reason I had to rename the file to main.py(even though it was a .py file already) and then it worked – sarwat zabeen Feb 25 '22 at 05:04
0

This might be a bit old, but there was no definite answer, so I will throw my two cents here.

I have faced the same issue, and there are two options:

1- Rename your file to main.py and it should work, but it does not make sense as you cannot name all your files main.py

2- Make sure that the path has no spaces in the name, even if you want to run it while you are in that folder.

I don't know why, but this is how I fixed it.

Ali
  • 37
  • 1
  • 5
0

Put the filepath in double or single quotes, it will work Like :

streamlit run 'filepath.py'

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Blue Robin Mar 07 '23 at 21:19