Question

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!

Était-ce utile?

La solution

Beautiful Soup 4's module is bs4.

from bs4 import BeautifulSoup

will work, or

import bs4

if you want to import the entire module.

Autres conseils

Simply run:

    pip install BeautifulSoup
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top