Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"ImportError: No module named BeautifulSoup" error even after installation

I'm running into the following error:

Traceback (most recent call last):
  File "C:\Python27\files\samplefileoutput.py", line 1, in <module>
    import BeautifulSoup
ImportError: No module named BeautifulSoup

when I try to run the following file:

import BeautifulSoup
f = open('c:\output.txt', 'a')
f.write('Hello World!\n')
f.close()

I thought my installation was successful. I am using a Windows 7 PC. I extracted the source tarball and then through the command line, typed "setup.py install" once I had changed the directory to the extracted BeautifulSoup folder. There didn't appear to be an error message during the install. It finished with this line:

Writing C:\Python27\Lib\site-packages\beautifulsoup4-4.3.2-py2.7.egg-info

Can anyone please provide some guidance? Thanks!

like image 361
Jerry Carson Avatar asked Jan 11 '23 20:01

Jerry Carson


1 Answers

Beautiful Soup 4's module is bs4.

from bs4 import BeautifulSoup

will work, or

import bs4

if you want to import the entire module.

like image 173
mipadi Avatar answered Jan 30 '23 02:01

mipadi