Bad interpreter error with streamlit run


I recently deleted Python 3.10 from my computer as I had both 3.10 and 3.9 installed. I’m now using 3.9. Now when I run streamlit hello/run, I get this error:

zsh: /opt/homebrew/bin/streamlit: bad interpreter: /opt/homebrew/opt/python@3.10/bin/python3.10: no such file or directory

I have reinstalled streamlit using python3.9 -m pip install streamlit and still nothing. There’s clearly some sort of missmatch between the streamlit command and the streamlit python3.9 is using.

Debug info

  • Streamlit version: 1.16.0
  • Python version: 3.9
  • OS version: MacOS 13.1
  • Browser version: Chrome 108.0.5359.124

Additional info as seen in this post

$ echo $PATH

$ which python3

$ which streamlit

$ python3
>>> import streamlit
>>> streamlit.__file__

Any help resolving would be much appreciated!

You can try to fix this by re-creating the symlink or modifying the path of the streamlit command.

ln -s /usr/bin/python3 /opt/homebrew/opt/python@3.10/bin/python3.10

This will create a symlink at the location where the previous python version was located so that streamlit command can use the new version path.

If the above doesn’t solve the issue, try modifying the path of the streamlit command.

Get the current path with

which streamlit

and then do…

nano <path-of-streamlit-command>

This will open up the streamlit command in nano editor.

Once inside the file, you should be able to find a line that starts with #! /usr/bin/env python, change the python version to python 3.9, and save the file.

After you’ve made changes, try running the streamlit hello command again, and see if it works.

Hope this helps! :balloon:


Thanks @ineelhere!

Changing the python version back to 3.9 in the streamlit command file fixed it :pray:

1 Like