0

Executing script with usage of from bs4 import BeautifulSoup gives the following error:

Traceback (most recent call last):
  File "C:\Users\Stewart\Desktop\dorkscan.py", line 13, in <module>
    from bs4 import BeautifulSoup  
  File "C:\PentestBox\base\python\Lib\site-packages\bs4\__init__.py", line 53  
    'You are trying to run the Python 2 version of Beautiful Soup under Python 3.  
 This will not work.'<>'You need to convert the code, either by installing it  
 (`python setup.py install`) or by running 2to3 (`2to3 -w bs4`).'
StegSchreck
  • 320
  • 4
  • 18
  • Even though you didn't ask a question, I think the answer is already in the stacktrace: `You need to convert the code, either by ...` – StegSchreck Jan 29 '18 at 20:16
  • i tried to python setup.py install but it gives me an error i tried the second thing it gives me nothing ! im really confused to what should i do – Adam SeinFeiter Jan 29 '18 at 22:42
  • Well it says you are trying to use python 2. What does `python --version` say? Did you try to call the script with `python3` instead? – StegSchreck Jan 29 '18 at 23:24
  • `You are trying to run the Python 2 version of Beautiful Soup under Python 3`. This is pretty much self-explanatory :) – pedropedro Jan 30 '18 at 14:31

1 Answers1

0

It appears you're trying to run the Python2 version of bs4 in Python3. To fix this, you should install the proper version of bs4.

  • If you want to write in python2 pip install BeautifulSoup4
  • python3 pip3 install BeautifulSoup4

In the future, you should pay attention to the error messages python gives. They are very informative. For instance, yours' says

'You are trying to run the Python 2 version of Beautiful Soup under Python 3. This will not work.'

The solution is given in the error message.

TMarks
  • 544
  • 4
  • 16
  • The proper name of the package (and thus the one that should be `pip install`ed) is [beautifulsoup4](https://pypi.python.org/pypi/beautifulsoup4), not [bs4](https://pypi.python.org/pypi/bs4). – jwodder Mar 02 '18 at 20:37
  • @jwodder Thanks for catching my mistake. I've edited the answer, though bs4 is a squatter package and would have installed BeautifulSoup4 as well. – TMarks Mar 02 '18 at 20:38