gpt4 book ai didi

python-2.7 - Python 2.7 的 pyPdf 不适用于 py2exe 和 cx_freeze?

转载 作者:行者123 更新时间:2023-12-04 05:03:48 24 4
gpt4 key购买 nike

每个人,

我使用 pyPdf 为 Python 2.7 编写了一个小程序。它已经在 Python 中进行了测试。现在我希望将它转换为 exe 文件以在 Windows 中运行它。 py2exe 或 cx_freeze 都不起作用。 exe 文件不运行。

看起来它在输出文件夹中不包含 pyPdf 模块。

文件夹结构是这样的:

dist\
tcl [folder]
tk [folder]
_ctypes.pyd
_tkinter.pyd
bz2.pyd
Filing.exe
python27.dll
tcl85.dll
tk85.dll
unicodedata.pyd

Filing.exe 是程序。

我尝试在命令窗口下运行exe,错误信息是这样的:
Traceback (most recent call last):
File "C:\python27\lib\site-packages\cx_Freeze\initscripts\console.py", line 27, in <module>
exec code in m.__dict__
File "filing.py", line 1, in <module>
ImportError: No module named pyPdf

请帮忙。

谢谢你们!

当我卡住它时,输出显示如下:
C:\Python27\Scripts>cxfreeze pypdf_test.py
copying C:\Python27\lib\site-packages\cx_Freeze\bases\Console.exe -> C:\Python27
\Scripts\dist\pypdf_test.exe
copying C:\Windows\system32\python27.dll -> C:\Python27\Scripts\dist\python27.dl
l
writing zip file C:\Python27\Scripts\dist\pypdf_test.exe

Name File
---- ----
m StringIO
m UserDict
m __builtin__
m __main__ pypdf_test.py
m _abcoll
m _codecs
m _codecs_cn
m _codecs_hk
m _codecs_iso2022
m _codecs_jp
m _codecs_kr
m _codecs_tw
m _multibytecodec
m _struct
m _warnings
m _weakref
m _weakrefset
m abc
m base64
m binascii
m bz2 C:\Python27\DLLs\bz2.pyd
m codecs
m copy
m copy_reg
m cx_Freeze__init__ C:\Python27\lib\site-packages\cx_Freeze\initscripts\
Console.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.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.cp424
m encodings.cp437
m encodings.cp500
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.string_escape
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 errno
m exceptions
m genericpath
m imp
m itertools
m linecache
m nt
m ntpath
m os
m posixpath
m quopri
m repr
m stat
m string
m stringprep
m strop
m struct
m sys
m traceback
m types
m unicodedata C:\Python27\DLLs\unicodedata.pyd
m warnings
m weakref
m zipimport
m zlib

Missing modules:
? pyPdf imported from __main__

copying C:\Python27\DLLs\bz2.pyd -> C:\Python27\Scripts\dist\bz2.pyd
copying C:\Python27\DLLs\unicodedata.pyd -> C:\Python27\Scripts\dist\unicodedata
.pyd

C:\Python27\Scripts>

好的。我检查了 pyPdf 的位置,它在这里:
>>import pyPdf
>>print pyPdf
module 'pyPdf' from 'C:\Python27\lib\site-packages\pypdf-1.13-py2.7.egg\pyPdf\__init__.pyc'

那么如何将 pyPdf 带到 exe 程序中呢?

最佳答案

重新发布作为答案:

安装在 .egg 目录中的模块似乎有些奇怪 - cx_Freeze 显然没有看到 setuptools 对路径的修改。

我有 filed a cx_Freeze issue关于它,但与此同时,简单的解决方案是将 Python 包复制到 PYTHONPATH 上的某个位置,例如 site-packages 文件夹。

关于python-2.7 - Python 2.7 的 pyPdf 不适用于 py2exe 和 cx_freeze?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15776313/

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