我使用urllib abd bs4在python中创建了一个脚本,我想使用它来执行它 cx-freeze.But我无法做到。它显示以下错误:
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,请求,重新,时间。 我该怎么办?
答案 0 :(得分:1)
如果构建失败,因为它们不会自动包含导入的库,您可以将它们添加到setup.py的包部分中。请参阅this帖子。
setup.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_freeze的文档。