Script runs fine in interpreter mode, in compiled version I get "No module named BS4"

271 views
Skip to first unread message

Stephen

unread,
May 6, 2012, 11:25:10 PM5/6/12
to beautifulsoup
I have a working BS4 script in Python 2.7, runs fine in the
interpreter mode - but when I compile it in Py2Exe I get an
"ImportError: No Module named bs4" message.

The script starts with these 4 lines:

#!/usr/bin/env python

from bs4 import BeautifulSoup
import re
from mechanize import Browser

What's happening here, why does it run one way, but not the other?

Leonard Richardson

unread,
May 7, 2012, 7:31:39 AM5/7/12
to beauti...@googlegroups.com
I don't know. It probably has something to do with your setup. Can you
"from mechanize import Browser" within a Py2Exe script? If so, what's
the difference between the way mechanize is installed on your system
and the way bs4 is isntalled?

Leonard

Stephen

unread,
May 7, 2012, 6:19:09 PM5/7/12
to beautifulsoup
I just commented out the line with bs4, compiled it and it ran using
the from mechanize import Browser line, so I guess the answer is yes.

As to the installation. I used the method recommended by the provider
of the BS4 module.

The Phyton27 folder does have both the mechanize & BeautifulSoup (3 &
4) content, so it should be able to find both.

I could try reinstalling BS4 with the current version.

Stephen

unread,
May 7, 2012, 6:34:46 PM5/7/12
to beautifulsoup
OK, I used "easy_install beautifulsoup4" to download and install BS4 -
and it looked to install properly in the Python27 directory.

But I got the same error - it runs in the interpreter but not after
compiling it.

On May 7, 4:31 am, Leonard Richardson <leona...@segfault.org> wrote:

Stephen

unread,
May 7, 2012, 10:31:58 PM5/7/12
to beautifulsoup
OK, I think I found the solution - I removed all of the BS files from
the Python27 directory - bs3 & bs4...then reinstalled just the BS4
using easy_install.

It works just as it should!

So I guess this is solved.
Reply all
Reply to author
Forward
0 new messages