简体   繁体   English

cx-freeze无法构建包含urllib和bs4的python

[英]cx-freeze not able to build python containing urllib and bs4

I have made a script in python using urllib abd bs4 and i want to make it executable using cx-freeze.But I am not able to do it. 我已经使用urllib abd bs4在python中创建了一个脚本,我想使用cx-freeze使它可执行。但是我做不到。 It shows the following error: 它显示以下错误:

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.

I have imported bs4, requests, re, time in my program. 我已经在程序中导入了bs4,res,re,time。 What should I do? 我该怎么办?

If builds fail because they aren't automatically including imported libraries you can add them into the package section of your setup.py. 如果构建因未自动包含导入的库而失败,则可以将其添加到setup.py的package部分中。 See this post. 看到这篇文章。

setup.py 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)])

You likely might only have to specify bs4, most modules should be found and included automatically. 您可能只需要指定bs4,应该会自动找到并包含大多数模块。 BS4 is known to have issues? 已知BS4有问题吗? so just try including that at first. 因此,请先尝试将其包括在内。

here is the docs for cx_freeze. 是cx_freeze的文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM