Reputation: 53
Today is a terrible day for me. I'm so frustrated because I've spent the last 4 hours trying to install beautifulsoup4
. I've searched every tutorial I can get my hands on.
It is installed on my computer, but when I do import bs4
on the shell it gives me this message:
Traceback (most recent call last):
File "<pyshell#13>", line 1, in <module>
import bs4
File "C:\Python34\lib\bs4\__init__.py", line 48
'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`).'
Does anyone have any idea what I can do? it tells me to run a command but it doesn't tell me how to run it.
Upvotes: 1
Views: 8318
Reputation: 1
I have the same issue. Got the following error multiple times. "'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).'"
This is what i did. (On MAC)
Step 1: Install python 2.7.(I had trouble installing BS4 with python3, so I use the latest version of serie 2 for installation.)
Step 2: Install latest version of beautiful soup. Then relocate the downloaded folder to somewhere easily accessible.
Step 3: Open TERMINAL and type in "cd *" (note: DON'T include the quote. Also, * in this case refer to the directory of the beautiful soup folder. If you don't know the directory of the folder, simply drag the folder to the terminal and you will get it!)
Step 4: Type "python setup.py install" in terminal(note: same thing. no quote)
Step 5: Wait for it to finish. Open IDLE/Python Shell
Step 6: Type "import os" Step 7: Type "os.chdir(***)" (Note: same directory like the above) Step 8: Type "from bs4 import BeautifulSoup"
AND you're good to go! GL
Upvotes: 0
Reputation: 87
I had the same issue after installing beautifulsoup4_4.5.1 on Python 3.4 via copying the .tar file. What worked for me was uninstalling the beautifulsoup and installing it again using the pip install method. If installation is successful, you will find bs4 in the list of installed modules. Here are the steps:
c:\Python34\Scripts\pip.exe uninstall beautifulsoup4
c:\Python34\Scripts\pip.exe install beautifulsoup4
c:\Python34\python.exe
help('modules')
from bs4 import BeautifulSoup
Upvotes: 0
Reputation: 11
Let's make this easy on you (If your using a 3x version of Python)
You are done.
Upvotes: 1
Reputation: 16
I had the same issue and it appears to be an issue with the latest release of beautifulsoup being installed via the TAR file.
I went back and got version 4.1.3 and it is now working for me in Python 3.4
Hope this helps.
Upvotes: 0
Reputation: 29
The answer is in the question. In the folder where bs4 is located (you could download bs4 in you work folder also), run :
2to3 -w bs4
Upvotes: 3