0
from bs4 import BeautifulSoup
html = '<div class="fun">something fun</div>'
soup = BeautifulSoup(html)
print(soup.find('div').string)
Это код. И я использую cxfreeze, чтобы сделать его исполняемым:При преобразовании скрипта с BeautifulSoup в .exe cx_freeze, я получаю ошибку
импорт SYS
from cx_Freeze import setup, Executable
script = 'test'
setup( name = "{}".format(script),
version = "1.0.0",
author = 'abraham',
options = {'build_exe': {'init_script':'Console'}},
executables = [Executable('{}.py'.format(script))])
But when I try to run it in shell, I get this error:
<pre>
G:\>G:\build\exe.win32-3.3\test.exe
Traceback (most recent call last):
File "E:\Python33\lib\site-packages\cx_freeze-4.3.3-py3.3-win32.egg\cx_Freeze\initscripts
\Console.py", line 27, in <module>
exec(code, m.__dict__)
File "test.py", line 1, in <module>
from bs4 import BeautifulSoup
File "c:\python\32-bit\3.3\lib\importlib\_bootstrap.py", line 1567, in _find_and_load
File "c:\python\32-bit\3.3\lib\importlib\_bootstrap.py", line 1534, in _find_and_load_unl
ocked
File "E:\Python33\lib\site-packages\bs4\__init__.py", line 30, in <module>
from .builder import builder_registry, ParserRejectedMarkup
File "c:\python\32-bit\3.3\lib\importlib\_bootstrap.py", line 1567, in _find_and_load
File "c:\python\32-bit\3.3\lib\importlib\_bootstrap.py", line 1534, in _find_and_load_unl
ocked
File "E:\Python33\lib\site-packages\bs4\builder\__init__.py", line 308, in <module>
from . import _htmlparser
File "c:\python\32-bit\3.3\lib\importlib\_bootstrap.py", line 1616, in _handle_fromlist
File "c:\python\32-bit\3.3\lib\importlib\_bootstrap.py", line 313, in _call_with_frames_r
emoved
File "c:\python\32-bit\3.3\lib\importlib\_bootstrap.py", line 1567, in _find_and_load
File "c:\python\32-bit\3.3\lib\importlib\_bootstrap.py", line 1534, in _find_and_load_unl
ocked
File "E:\Python33\lib\site-packages\bs4\builder\_htmlparser.py", line 7, in <module>
from html.parser import (
File "c:\python\32-bit\3.3\lib\importlib\_bootstrap.py", line 1567, in _find_and_load
File "c:\python\32-bit\3.3\lib\importlib\_bootstrap.py", line 1534, in _find_and_load_unl
ocked
File "E:\Python33\lib\html\parser.py", line 70, in <module>
""", re.VERBOSE)
File "c:\python\32-bit\3.3\lib\re.py", line 214, in compile
File "c:\python\32-bit\3.3\lib\re.py", line 281, in _compile
File "c:\python\32-bit\3.3\lib\sre_compile.py", line 498, in compile
File "c:\python\32-bit\3.3\lib\sre_compile.py", line 483, in _code
File "c:\python\32-bit\3.3\lib\sre_compile.py", line 75, in _compile
File "c:\python\32-bit\3.3\lib\sre_compile.py", line 362, in _simple
sre_constants.error: nothing to repeat
Кстати, я установил BeautifulSoup используя mingw32 в качестве компилятора. и cx_freeze упомянутые там могут быть некоторые модули отсутствуют, а именно:
Missing modules:
? _dummy_threading imported from dummy_threading
? _emx_link imported from os
? cchardet imported from bs4.dammit
? ce imported from os
? chardet imported from bs4.dammit
? doctest imported from heapq
? getopt imported from base64, quopri
? html5lib imported from bs4.builder._html5lib
? html5lib.constants imported from bs4.builder._html5lib
? iconv_codec imported from bs4.dammit
? lxml imported from bs4.builder._lxml
? org.python.core imported from copy
? os.path imported from os
? os2 imported from os
? os2emxpath imported from os
? posix imported from os
? pwd imported from posixpath
? subprocess imported from os
This is not necessarily a problem - the modules may not be needed on this platform.
Любая помощь будет оценена.
Эта ошибка возникает, когда cx_Freeze создается против другой младшей версии Python, чем вы используете для замораживания. –
версия python - 3.3.5, а cx_freeze - easy_install. И это 4.3.3. Как это исправить? – Yearner