gpt4 book ai didi

python - pyodbc python 3.4 出现 cx_freeze 错误

转载 作者:太空宇宙 更新时间:2023-11-03 18:12:50 33 4
gpt4 key购买 nike

这与 cx_freeze error with pyodbc 几乎完全相同除了添加小数作为特定包含不起作用:卡住正常,但是当尝试运行可执行文件时,我得到:

Traceback (most recent call last):
File "C:\Python34\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27
, in <module>
exec(code, m.__dict__)
File "my_program.py", line 9, in <module>
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2214, in _find_a
nd_load
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 2203, in _find_a
nd_load_unlocked
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1191, in _load_u
nlocked
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1161, in _load_b
ackward_compatible
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 539, in _check_n
ame_wrapper
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 1692, in load_mo
dule
File "c:\python\32-bit\3.4\lib\importlib\_bootstrap.py", line 321, in _call_wi
th_frames_removed
RuntimeError: Unable to import decimal

当我添加十进制作为包含时,我看到输出文件夹中包含 _decimal.pyd,但仍然出现相同的运行时错误。

这是我的 setup.py:

import sys
from cx_Freeze import setup, Executable


build_exe_options = {
'includes': ['decimal'],
'include_files': ['connection settings.cfg']
}

setup(name = 'my_program',
version = '0.0.1',
description = """This program does stuff.""",
options = {'build_exe':build_exe_options},
executables = [Executable('my_program.py')]
)

我正在使用:

  • Windows 7
  • Python 3.4,32 位
  • cx-Freeze 4.3.3
  • pyodbc 3.0.7

更新:这是构建时的输出:

C:\Users\my_name\Documents\Python>python my_program.py build
running build
running build_exe
creating directory build\exe.win32-3.4
copying C:\Python34\lib\site-packages\cx_Freeze\bases\Console.exe -> build\exe.w
in32-3.4\my_program.exe
copying C:\Windows\system32\python34.dll -> build\exe.win32-3.4\python34.dll
*** WARNING *** unable to create version resource
install pywin32 extensions first
writing zip file build\exe.win32-3.4\library.zip

Name File
---- ----
m BUILD_CONSTANTS
m ConfigParser C:\Python34\lib\ConfigParser.py
m __future__ C:\Python34\lib\__future__.py
m _ast
m _bisect
m _bootlocale
m _bz2 C:\Python34\DLLs\_bz2.pyd
m _codecs
m _codecs_cn
m _codecs_hk
m _codecs_iso2022
m _codecs_jp
m _codecs_kr
m _codecs_tw
m _collections
m _collections_abc
m _datetime
m _decimal C:\Python34\DLLs\_decimal.pyd
m _dummy_thread
m _functools
m _hashlib C:\Python34\DLLs\_hashlib.pyd
m _heapq
m _imp
m _io
m _locale
m _lzma C:\Python34\DLLs\_lzma.pyd
m _md5
m _multibytecodec
m _opcode
m _operator
m _osx_support C:\Python34\lib\_osx_support.py
m _random
m _sha1
m _sha256
m _sha512
m _socket C:\Python34\DLLs\_socket.pyd
m _sre
m _ssl C:\Python34\DLLs\_ssl.pyd
m _stat
m _string
m _strptime
m _struct
m _thread
m _threading_local
m _warnings
m _weakref
m _weakrefset
m _winapi
m abc
m argparse
m array
m ast C:\Python34\lib\ast.py
m atexit
m base64
m bdb C:\Python34\lib\bdb.py
m binascii
m bisect C:\Python34\lib\bisect.py
m builtins
m bz2
m calendar
m cmd C:\Python34\lib\cmd.py
m code C:\Python34\lib\code.py
m codecs
m codeop C:\Python34\lib\codeop.py
P collections
m collections.abc
m configparser C:\Python34\lib\configparser.py
m contextlib
m copy
m copyreg
m cx_Freeze__init__ C:\Python34\lib\site-packages\cx_Freeze\initscripts\
Console.py
m datetime
m decimal C:\Python34\lib\decimal.py
m difflib C:\Python34\lib\difflib.py
m dis C:\Python34\lib\dis.py
P distutils C:\Python34\lib\distutils\__init__.py
m distutils.debug C:\Python34\lib\distutils\debug.py
m distutils.errors C:\Python34\lib\distutils\errors.py
m distutils.log C:\Python34\lib\distutils\log.py
m distutils.spawn C:\Python34\lib\distutils\spawn.py
m distutils.sysconfig C:\Python34\lib\distutils\sysconfig.py
m distutils.text_file C:\Python34\lib\distutils\text_file.py
m doctest C:\Python34\lib\doctest.py
m dummy_threading
P email C:\Python34\lib\email\__init__.py
m email._encoded_words C:\Python34\lib\email\_encoded_words.py
m email._header_value_parser C:\Python34\lib\email\_header_value_parser.py
m email._parseaddr C:\Python34\lib\email\_parseaddr.py
m email._policybase C:\Python34\lib\email\_policybase.py
m email.base64mime C:\Python34\lib\email\base64mime.py
m email.charset C:\Python34\lib\email\charset.py
m email.contentmanager C:\Python34\lib\email\contentmanager.py
m email.encoders C:\Python34\lib\email\encoders.py
m email.errors C:\Python34\lib\email\errors.py
m email.feedparser C:\Python34\lib\email\feedparser.py
m email.generator C:\Python34\lib\email\generator.py
m email.header C:\Python34\lib\email\header.py
m email.headerregistry C:\Python34\lib\email\headerregistry.py
m email.iterators C:\Python34\lib\email\iterators.py
m email.message C:\Python34\lib\email\message.py
m email.parser C:\Python34\lib\email\parser.py
m email.policy C:\Python34\lib\email\policy.py
m email.quoprimime C:\Python34\lib\email\quoprimime.py
m email.utils C:\Python34\lib\email\utils.py
P encodings
m encodings.aliases
m encodings.ascii
m encodings.base64_codec
m encodings.big5
m encodings.big5hkscs
m encodings.bz2_codec
m encodings.charmap
m encodings.cp037
m encodings.cp1006
m encodings.cp1026
m encodings.cp1125
m encodings.cp1140
m encodings.cp1250
m encodings.cp1251
m encodings.cp1252
m encodings.cp1253
m encodings.cp1254
m encodings.cp1255
m encodings.cp1256
m encodings.cp1257
m encodings.cp1258
m encodings.cp273
m encodings.cp424
m encodings.cp437
m encodings.cp500
m encodings.cp65001
m encodings.cp720
m encodings.cp737
m encodings.cp775
m encodings.cp850
m encodings.cp852
m encodings.cp855
m encodings.cp856
m encodings.cp857
m encodings.cp858
m encodings.cp860
m encodings.cp861
m encodings.cp862
m encodings.cp863
m encodings.cp864
m encodings.cp865
m encodings.cp866
m encodings.cp869
m encodings.cp874
m encodings.cp875
m encodings.cp932
m encodings.cp949
m encodings.cp950
m encodings.euc_jis_2004
m encodings.euc_jisx0213
m encodings.euc_jp
m encodings.euc_kr
m encodings.gb18030
m encodings.gb2312
m encodings.gbk
m encodings.hex_codec
m encodings.hp_roman8
m encodings.hz
m encodings.idna
m encodings.iso2022_jp
m encodings.iso2022_jp_1
m encodings.iso2022_jp_2
m encodings.iso2022_jp_2004
m encodings.iso2022_jp_3
m encodings.iso2022_jp_ext
m encodings.iso2022_kr
m encodings.iso8859_1
m encodings.iso8859_10
m encodings.iso8859_11
m encodings.iso8859_13
m encodings.iso8859_14
m encodings.iso8859_15
m encodings.iso8859_16
m encodings.iso8859_2
m encodings.iso8859_3
m encodings.iso8859_4
m encodings.iso8859_5
m encodings.iso8859_6
m encodings.iso8859_7
m encodings.iso8859_8
m encodings.iso8859_9
m encodings.johab
m encodings.koi8_r
m encodings.koi8_u
m encodings.latin_1
m encodings.mac_arabic
m encodings.mac_centeuro
m encodings.mac_croatian
m encodings.mac_cyrillic
m encodings.mac_farsi
m encodings.mac_greek
m encodings.mac_iceland
m encodings.mac_latin2
m encodings.mac_roman
m encodings.mac_romanian
m encodings.mac_turkish
m encodings.mbcs
m encodings.palmos
m encodings.ptcp154
m encodings.punycode
m encodings.quopri_codec
m encodings.raw_unicode_escape
m encodings.rot_13
m encodings.shift_jis
m encodings.shift_jis_2004
m encodings.shift_jisx0213
m encodings.tis_620
m encodings.undefined
m encodings.unicode_escape
m encodings.unicode_internal
m encodings.utf_16
m encodings.utf_16_be
m encodings.utf_16_le
m encodings.utf_32
m encodings.utf_32_be
m encodings.utf_32_le
m encodings.utf_7
m encodings.utf_8
m encodings.utf_8_sig
m encodings.uu_codec
m encodings.zlib_codec
m enum C:\Python34\lib\enum.py
m errno
m fnmatch C:\Python34\lib\fnmatch.py
m ftplib C:\Python34\lib\ftplib.py
m functools
m gc
m genericpath
m getopt C:\Python34\lib\getopt.py
m getpass C:\Python34\lib\getpass.py
m gettext
m glob C:\Python34\lib\glob.py
m gzip C:\Python34\lib\gzip.py
m hashlib C:\Python34\lib\hashlib.py
m heapq
P html C:\Python34\lib\html\__init__.py
m html.entities C:\Python34\lib\html\entities.py
P http C:\Python34\lib\http\__init__.py
m http.client C:\Python34\lib\http\client.py
m http.cookiejar C:\Python34\lib\http\cookiejar.py
m http.server C:\Python34\lib\http\server.py
m imp C:\Python34\lib\imp.py
P importlib C:\Python34\lib\importlib\__init__.py
P importlib C:\Python34\lib\importlib\__init__.py
m importlib._bootstrap
m importlib._bootstrap C:\Python34\lib\importlib\_bootstrap.py
m importlib.machinery C:\Python34\lib\importlib\machinery.py
m importlib.util C:\Python34\lib\importlib\util.py
m inspect C:\Python34\lib\inspect.py
m io
m itertools
m keyword
m linecache
m locale
P logging C:\Python34\lib\logging\__init__.py
m lzma C:\Python34\lib\lzma.py
m my_program__main__ my_program.py
m marshal
m math
m mimetypes C:\Users\clee\Documents\Python\mimetypes.py
m msvcrt
m nt
m ntpath
m nturl2path C:\Python34\lib\nturl2path.py
m numbers C:\Python34\lib\numbers.py
m opcode C:\Python34\lib\opcode.py
m operator
m optparse
m os
m pdb C:\Python34\lib\pdb.py
m pkgutil C:\Python34\lib\pkgutil.py
m platform C:\Python34\lib\platform.py
m plistlib C:\Python34\lib\plistlib.py
m posixpath
m pprint C:\Python34\lib\pprint.py
m py_compile C:\Python34\lib\py_compile.py
m pydoc C:\Python34\lib\pydoc.py
P pydoc_data C:\Python34\lib\pydoc_data\__init__.py
m pydoc_data.topics C:\Python34\lib\pydoc_data\topics.py
m pyexpat C:\Python34\DLLs\pyexpat.pyd
m pyodbc C:\Python34\lib\site-packages\pyodbc-3.0.7-py3.4-win
32.egg\pyodbc.pyd
m quopri
m random C:\Python34\lib\random.py
m re
m reprlib
m select C:\Python34\DLLs\select.pyd
m selectors C:\Python34\lib\selectors.py
m shlex C:\Python34\lib\shlex.py
m shutil C:\Python34\lib\shutil.py
m signal
m socket C:\Python34\lib\socket.py
m socketserver C:\Python34\lib\socketserver.py
m sre_compile
m sre_constants
m sre_parse
m ssl C:\Python34\lib\ssl.py
m stat
m string
m stringprep
m struct
m subprocess C:\Python34\lib\subprocess.py
m sys
m tarfile C:\Python34\lib\tarfile.py
m tempfile C:\Python34\lib\tempfile.py
m textwrap
m threading
m time
m token
m tokenize
m traceback
m tty C:\Python34\lib\tty.py
m types
m unicodedata C:\Python34\DLLs\unicodedata.pyd
P unittest C:\Python34\lib\unittest\__init__.py
m unittest.case C:\Python34\lib\unittest\case.py
m unittest.loader C:\Python34\lib\unittest\loader.py
m unittest.main C:\Python34\lib\unittest\main.py
m unittest.result C:\Python34\lib\unittest\result.py
m unittest.runner C:\Python34\lib\unittest\runner.py
m unittest.signals C:\Python34\lib\unittest\signals.py
m unittest.suite C:\Python34\lib\unittest\suite.py
m unittest.util C:\Python34\lib\unittest\util.py
P urllib C:\Python34\lib\urllib\__init__.py
m urllib.error C:\Python34\lib\urllib\error.py
m urllib.parse C:\Python34\lib\urllib\parse.py
m urllib.request C:\Python34\lib\urllib\request.py
m urllib.response C:\Python34\lib\urllib\response.py
m uu C:\Python34\lib\uu.py
m warnings
m weakref
m webbrowser C:\Python34\lib\webbrowser.py
m winreg
P xml C:\Python34\lib\xml\__init__.py
P xml.dom C:\Python34\lib\xml\dom\__init__.py
m xml.dom.NodeFilter C:\Python34\lib\xml\dom\NodeFilter.py
m xml.dom.domreg C:\Python34\lib\xml\dom\domreg.py
m xml.dom.expatbuilder C:\Python34\lib\xml\dom\expatbuilder.py
m xml.dom.minicompat C:\Python34\lib\xml\dom\minicompat.py
m xml.dom.minidom C:\Python34\lib\xml\dom\minidom.py
m xml.dom.pulldom C:\Python34\lib\xml\dom\pulldom.py
m xml.dom.xmlbuilder C:\Python34\lib\xml\dom\xmlbuilder.py
P xml.parsers C:\Python34\lib\xml\parsers\__init__.py
m xml.parsers.expat C:\Python34\lib\xml\parsers\expat.py
P xml.sax C:\Python34\lib\xml\sax\__init__.py
m xml.sax._exceptions C:\Python34\lib\xml\sax\_exceptions.py
m xml.sax.expatreader C:\Python34\lib\xml\sax\expatreader.py
m xml.sax.handler C:\Python34\lib\xml\sax\handler.py
m xml.sax.saxutils C:\Python34\lib\xml\sax\saxutils.py
m xml.sax.xmlreader C:\Python34\lib\xml\sax\xmlreader.py
m zipfile C:\Python34\lib\zipfile.py
m zipimport
m zlib

Missing modules:
? __main__ imported from bdb, pdb
? _dummy_threading imported from dummy_threading
? _posixsubprocess imported from subprocess
? _scproxy imported from urllib.request
? ce imported from os
? grp imported from shutil, tarfile
? java.lang imported from platform, xml.sax._exceptions
? org.python.core imported from copy, xml.sax
? os.path imported from os, pkgutil, py_compile, shutil, unittest.util
? posix imported from os
? pwd imported from getpass, http.server, posixpath, shutil, tarfile, webbrowser

? termios imported from getpass, tty
? vms_lib imported from platform
? win32api imported from platform
? win32con imported from platform
This is not necessarily a problem - the modules may not be needed on this platfo
rm.

C:\Python34\lib\site-packages\cx_Freeze\freezer.py:574: UserWarning: Duplicate n
ame: 'importlib/__init__.pyc'
outFile.writestr(zinfo, data)
copying C:\Python34\DLLs\_bz2.pyd -> build\exe.win32-3.4\_bz2.pyd
copying C:\Python34\DLLs\_decimal.pyd -> build\exe.win32-3.4\_decimal.pyd
copying C:\Python34\DLLs\_hashlib.pyd -> build\exe.win32-3.4\_hashlib.pyd
copying C:\Python34\DLLs\_lzma.pyd -> build\exe.win32-3.4\_lzma.pyd
copying C:\Python34\DLLs\_socket.pyd -> build\exe.win32-3.4\_socket.pyd
copying C:\Python34\DLLs\_ssl.pyd -> build\exe.win32-3.4\_ssl.pyd
copying C:\Python34\DLLs\pyexpat.pyd -> build\exe.win32-3.4\pyexpat.pyd
copying C:\Python34\lib\site-packages\pyodbc-3.0.7-py3.4-win32.egg\pyodbc.pyd ->
build\exe.win32-3.4\pyodbc.pyd
copying C:\Python34\DLLs\select.pyd -> build\exe.win32-3.4\select.pyd
copying C:\Python34\DLLs\unicodedata.pyd -> build\exe.win32-3.4\unicodedata.pyd
copying connection settings.cfg -> build\exe.win32-3.4\connection settings.cfg

最佳答案

我在非常相似的设置中遇到了同样的问题,唯一可以使其工作的方法是将 importdecimal 添加到我的 python 脚本中,尝试将 importdecimal 添加到 my_program.py

关于python - pyodbc python 3.4 出现 cx_freeze 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25559947/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com