From bs4 import BeautifulSoup issue on deploying an app

Hi everyone,

I did a lot of tries to find that a part of my app is no working because she needs BeautifulSoup and not beautifulsoup4.
I mean, I am actually checking if there is a difference but it appears that if I put BeautifulSoup instead of beautifulsoup4 in the requirements file I get this error :
WARNING: Discarding https://files.pythonhosted.org/packages/33/fe/15326560884f20d792d3ffc7fe8f639aab88647c9d46509a240d9bfbb6b1/BeautifulSoup-3.2.0.tar.gz#sha256=0dc52d07516c1665c9dd9f0a390a7a054bfb7b147a50b2866fb116b8909dfd37 (from Links for BeautifulSoup). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.


ERROR: Could not find a version that satisfies the requirement BeautifulSoup (from versions: 3.2.0, 3.2.1, 3.2.2)


ERROR: No matching distribution found for BeautifulSoup

[client] Spinning up manager process...
[manager] installer returned a non-zero exit code
[manager] Error during processing dependencies! Please fix the error and push an update, or try restarting the app.

I am pretty sure that bs4 don’t stand for beautifulsoup4 because when I test it I get this on my computer: ModuleNotFoundError: No module named ‘beautifulsoup4’

Does anybody already face this problem with bs4 ? And how to translate the sentence “from bs4 import BeautifulSoup” from my script to the requirements files ?

Thank you,

Bastien

Hi @BastienChicot,

It seems that bs4 is the 4th version of BeautifulSoup, and it is recommended to use the newer version when coding these days.

In the “Installing Beautiful Soup” section:
“The BeautifulSoup package is not what you want. That’s the previous major release, Beautiful Soup 3. Lots of software uses BS3, so it’s still available, but if you’re writing new code you should install beautifulsoup4 .)”

Here is the docs I found: Beautiful Soup Documentation — Beautiful Soup 4.9.0 documentation

I don’t know all the subtle differences between the packages, but I suppose the easiest would be to change your requirements to use the newest version by adding beautifulsoup4 as the package.

Any reason you’re not using the most up-to-date version of BeautifulSoup?

Happy Streamlit-ing!
Marisa

Hi @Marisa_Smith ,

First, I’d like to thank you for your answer.

To answer your question, on my computer, the version of beautifulsoup is the 4.9.0. I put it in the requirements files when I tried to deploy my app.
Looking at the documentation, it seems like I’m usigng BeautifulSoup the right way, I must miss something.
In my scripts I have the line “from bs4 import BeautifulSoup” as they do in the link you send me and in my requirements file I have this line : beautifulsoup4==4.9.0

I did a few tests, line by line on my app and she looks to stop the calculation when she encounter this line : soup = BeautifulSoup(r_html,‘html.parser’)
A really common line in scraping with python.

I might need to do something different for the two tables using this method.
Could there be any scraping limitation and forbidden websites while an app is deployed on streamlit ?

Have a nice day
Bastien

Hey @BastienChicot,

Can you post your Github repo your deploying from here?

I want to take a look at the requirements.txt file, and try deploying from my end to reproduce the package installation issue your having.

To answer this, no we don’t block/deny the beautiful soup package, it should install just like any other package!

Happy Streamlit-ing!
Marisa

Hi,

Yes of course : GitHub - BastienChicot/NBApp_streamlit

The requirements files didn’t change but while I haven’t found a solution for scrapping the table I need, I slightly change the code of the app. The instructions that are usually scraping are in comments in the file Services/stats_joueurs.py

Thank you for everything,

Bastien