I keep getting this traceback. I've used BeautifulSoup before with Python3 so I'm kind of confused as to why I would get this error now...
'''Traceback (most recent call last):
File "spider.py", line 7, in
from bs4 import BeautifulSoup
File "/home/cambam/Desktop/Python/Coursera/P4E/CapStone/pagerank/bs4/init.py", line 54
'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).'
^
SyntaxError: invalid syntax
'''
0
votes
2 Answers
1
votes
Obtaining python2 code in the first place sounds inconvenient. Better to grab the right version at the outset.
Delete the old Soup code you downloaded, and grab a fresh copy:
$ python3 -m pip install beautifulsoup4
If you look at which pip or pip --version you may notice that it corresponds to python2. Using the -m module syntax above will ensure that you get a proper python3 version that installs libraries where python3 will look for them.