-1

I'm following this https://app.pluralsight.com/guides/dockerfile-for-python-web-projects

and have a requirements.txt file containing:

streamlit

Running

pip install -r requirements.txt

I get:

ERROR: Invalid requirement: 'import streamlit as st' (from line 1 of requirements.txt)

What's the problem?

Note, I just asked this here which was closed: ERROR: Invalid requirement: 'import streamlit as st' however the suggested answer (How to install from requirements.txt? ) does not work.

E.g. if I do pip freeze > requirements.txt I get hundreds of pip packages and don't get streamlit.

Snowcrash
  • 80,579
  • 89
  • 266
  • 376
  • 2
    No. Your `requirements.txt.` does NOT contain `steamlit`. It contains `import streamlit as st`, as the error says. It looks more as it you're trying to install from your .py file (first line being import). Check the contents again. It should contain package name per line only or packagename==version – h4z3 Oct 26 '21 at 14:29
  • This error occurs when building a docker image? Can you add the Dockerfile? – Iain Shelvington Oct 26 '21 at 14:29

2 Answers2

1

from above error it looks like you added import streamlit as st in your requirements.txt just replace it with streamlit because requirements.txt wants package name not python import statement.

read this for more info about how to write requirements.txt

Kunal Sharma
  • 416
  • 3
  • 12
0

Your requirements.txt should contain only the package name. You are facing this because you have an import statement. Imports are used in a python script. It doesn't work as a python command. Remove the import statement and you will be good to go.