0

I installed Python 3.6 and ran pip from the command line to install numpy and beautiful soup 4, like so:

pip install beautifulsoup4

Then when I tried to run python files with

from bs4 import BeautifulSoup

it would give me the error that the module wasn't found, although I checked and it was installed.

Then I created a virtual environment using virtualenv, installed beautifulsoup the same way using pip on the virtual environment and ran a python file from that environment. It worked no problem. What's the deal?

Nicholas A. Randall
  • 421
  • 1
  • 5
  • 13
  • 2
    The version of `python` you ran was different from the one for which `pip` installed the packages. – deceze Aug 26 '17 at 20:19
  • 2
    You probably should have used pip3 install (but that is a bit dependent on the setup). – sascha Aug 26 '17 at 20:20
  • like @sascha said try using pip3 install beautifulsoup4 and tells if it works. – ands Aug 26 '17 at 20:30
  • 3
    Better: always use `python -m pip install` so you *know* it's the right python. Even `pip3` is prone to 3.4 vs 3.5 vs 3.6 mismatches. – o11c Aug 26 '17 at 20:35
  • I just checked using pip3 install and python -m pip install and it said Requirement already satisfied on both, under python version 3.6. Possibly my IDE was trying to run python 3.4 when I tried using beautifulsoup the first time but I'm pretty sure I switched the environment to the path of python 3.6. Any answers? – Nicholas A. Randall Aug 27 '17 at 16:56
  • You need to do pip install bs4 as the package isn't named BeautilfulSoup. For the same reason you do the from bs4 import... – jlaur Aug 31 '17 at 18:20
  • @jlaur I'm not sure that's it, because I did pip install beautifulsoup4 command when I had virtual environment activated and it installed and worked just fine. – Nicholas A. Randall Sep 01 '17 at 19:42
  • Try going through this: https://stackoverflow.com/a/41771160/8240959 – jlaur Sep 01 '17 at 20:31

0 Answers0