cxfreeze无法构建包含urllib和bs4的python

2024-05-15 10:02:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我用python编写了一个使用urllib abd bs4的脚本,我想使用 cx-别动。但是我做不到。显示以下错误:

Missing modules:
? Carbon imported from plistlib
? Carbon.File imported from plistlib
? Carbon.Files imported from plistlib
? MacOS imported from platform
? OpenSSL.SSL imported from requests.packages.urllib3.contrib.pyopenssl
? _dummy_threading imported from dummy_threading
? _emx_link imported from os
? _scproxy imported from urllib
? bs4.builder imported from bs4
? builtins imported from requests.packages.urllib3.packages.six
? cchardet imported from bs4.dammit
? ce imported from os
? chardet imported from bs4.dammit
? fcntl imported from subprocess
? gestalt imported from platform
? http imported from requests.compat
? http.client imported from requests.packages.urllib3.connectionpool
? http.cookies imported from requests.compat
? iconv_codec imported from bs4.dammit
? java.lang imported from platform
? ndg.httpsclient.ssl_peer_verification imported from requests.packages.urllib3.
contrib.pyopenssl
? ndg.httpsclient.subj_alt_name imported from requests.packages.urllib3.contrib.
pyopenssl
? netbios imported from uuid
? org.python.core imported from copy, pickle
? os.path imported from os, requests.certs, shlex
? os2 imported from os
? os2emxpath imported from os
? posix imported from os
? pwd imported from getpass, posixpath
? pyasn1.codec.der imported from requests.packages.urllib3.contrib.pyopenssl
? queue imported from requests.packages.urllib3.connectionpool
? riscos imported from os
? riscosenviron imported from os
? riscospath imported from os
? rourl2path imported from urllib
? simplejson imported from requests.compat
? termios imported from getpass
? urllib.parse imported from requests.compat, requests.packages.urllib3.request
? urllib.request imported from requests.compat
? vms_lib imported from platform
? win32api imported from platform
? win32con imported from platform
? win32pipe imported from platform
? win32wnet imported from uuid
This is not necessarily a problem - the modules may not be needed on this platfo
rm.

我已经在我的程序中导入了bs4,requests,re,time。 我该怎么办?在


Tags: fromospackagesurllibcontribrequestsplatformcompat
1条回答
网友
1楼 · 发布于 2024-05-15 10:02:18

如果生成失败是因为它们没有自动包含导入的库,则可以将它们添加到设置.py. 见this帖子。在

在设置.py在

import sys
from cx_Freeze import setup, Executable

# Dependencies are automatically detected, but it might need fine tuning.
build_exe_options = {"packages": ["bs4, urllib, requests"], "excludes": [""]}

# GUI applications require a different base on Windows (the default is for a
# console application).
base = None
if sys.platform == "win32":
    base = "Win32GUI"

setup(  name = "my-app",
        version = "0.9.0",
        description = "Copyright 2013",
        options = {"build_exe": build_exe_options},
        executables = [Executable("my_module.py", base=base)])

您可能只需要指定bs4,大多数模块都应该自动找到并包含进来。BS4 is known to have issues?所以先试着把它包括进去。在

here是用于cx冻结的文档。在

相关问题 更多 >