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.

  • 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 Sep 12 '20 at 18:17
  • 1
    Does this answer your question? [What are the risks of running 'sudo pip'?](https://stackoverflow.com/questions/21055859/what-are-the-risks-of-running-sudo-pip) – Josh Correia Feb 25 '22 at 08:10

2 Answers2

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.

larsks
  • 277,717
  • 41
  • 399
  • 399
  • 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 Sep 12 '20 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 Sep 12 '20 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.

Howard_Roark
  • 4,088
  • 1
  • 14
  • 24