0

I am very new to coding in general but wanted to learn web scraping for the upcoming NFL season so beautifulsoup was necessary to download. To install it, I inputed

sudo pip install bs4

in my terminal as instructed by this video here. https://www.youtube.com/watch?v=TVfhWr2ayKQ&ab_channel=OfficialJLara

After reading up a little on it, it seems to be the general consensus to not use sudo pip as it gives malicious files easy access to my computer. Did I do something tragically wrong here or is bs4 generally safe to download, even with using sudo pip? Sorry for being such a novice.

2
  • You should either install into a virtual environment, or if you want to install system-wide then use your operating system's package manager if a suitably packaged version is available. What exactly is your OS?
    – alani
    Commented Sep 12, 2020 at 18:17
  • 1
    Does this answer your question? What are the risks of running 'sudo pip'? Commented Feb 25, 2022 at 8:10

2 Answers 2

1

It's not so much that it gives malicious files access to your computer (which, sure, it could), but also that you've just replaced the packaged version of bs4 and potentially any of its dependencies with versions from pip. This could lead to system commands breaking if (a) they are based on Python and (b) they are incompatible with the updated version of a module installed by pip.

It's best to never use pip to install system-wide packages. You should either operate in your own account (pip install --user ...) or install things into a virtual environment specific to your project.

2
  • thank you for answering, I will definitely avoid using it from now on. Do you happen to know if bs4 is generally a safe way to download beautifulsoup?
    – danglerrs
    Commented Sep 12, 2020 at 18:18
  • I'm not sure I follow your question. bs4 is the name of the package that provides the BeautifulSoup class. You need to install that package if you want to use beautiful soup.
    – larsks
    Commented Sep 12, 2020 at 19:08
0

The answers in this question are good: What are the risks of running 'sudo pip'?

You should just uninstall it and reinstall it without using sudo if you're concerned.

1
  • ya and then you can do pip show bs4 to see if it's gone or pip freeze to see what you have installed Commented Sep 12, 2020 at 18:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.