我想将我的python项目打包成UNIX可执行文件。为此,我尝试了py2exe,cxfreeze和pyInstaller,但没有任何效果。希望你可以帮我使用pyinstaller。所以这就是:
我从http://www.pyinstaller.org/下载了pyinstaller-2.0的zip文件并解压缩。
在文件夹中,我运行python pyinstaller.py ../helloworld.py
(结尾列出的输出)。
然后我尝试执行文件:./helloworld/dist/helloworld/helloworld
这给了我输出:
mod is NULL - structTraceback (most recent call last):
File "/usr/lib/python2.7/struct.py", line 1, in <module>
from _struct import *
ImportError: No module named _struct
mod is NULL - archiveTraceback (most recent call last):
File "/home/jelle/Downloads/pyinstaller-1.5.1/archive.py", line 42, in <module>
import struct
ImportError: No module named struct
Traceback (most recent call last):
File "<string>", line 25, in <module>
ImportError: No module named archive
我正在使用Ubuntu 12.04和Python 2.7.3。我的PYTHONPATH包括/usr/lib/python2.7。看起来问题是缺少模块_struct,但我不知道在哪里找到它。我已经尝试过pyinstaller 1.5.1和开发版本,但这里都没有。
请帮忙!
python pyinstaller.py ../helloworld.py
的输出:
7 INFO: wrote /home/jelle/Downloads/pyinstaller-2.0/helloworld/helloworld.spec
27 INFO: UPX is not available.
583 INFO: checking Analysis
583 INFO: building Analysis because out00-Analysis.toc non existent
583 INFO: running Analysis out00-Analysis.toc
702 INFO: Analyzing /home/jelle/Downloads/pyinstaller-2.0/support/_pyi_bootstrap.py
1570 INFO: Analyzing /home/jelle/Downloads/pyinstaller-2.0/PyInstaller/loader/archive.py
1637 INFO: Analyzing /home/jelle/Downloads/pyinstaller-2.0/PyInstaller/loader/carchive.py
1701 INFO: Analyzing /home/jelle/Downloads/pyinstaller-2.0/PyInstaller/loader/iu.py
1720 INFO: Analyzing ../helloworld.py
1721 INFO: Hidden import 'encodings' has been found otherwise
1721 INFO: Looking for run-time hooks
1721 INFO: Analyzing rthook /home/jelle/Downloads/pyinstaller-2.0/support/rthooks/pyi_rth_encodings.py
2197 INFO: Looking for Python library libpython2.7.so
objdump: section '.dynamic' mentioned in a -j option, but not found in any input file
2308 INFO: Warnings written to /home/jelle/Downloads/pyinstaller-2.0/helloworld/build/pyi.linux2/helloworld/warnhelloworld.txt
2311 INFO: checking PYZ
2311 INFO: rebuilding out00-PYZ.toc because out00-PYZ.pyz is missing
2312 INFO: building PYZ out00-PYZ.toc
2706 INFO: checking PKG
2706 INFO: rebuilding out00-PKG.toc because out00-PKG.pkg is missing
2706 INFO: building PKG out00-PKG.pkg
2711 INFO: checking EXE
2712 INFO: rebuilding out00-EXE.toc because helloworld missing
2712 INFO: building EXE from out00-EXE.toc
2772 INFO: Appending archive to EXE /home/jelle/Downloads/pyinstaller-2.0/helloworld/build/pyi.linux2/helloworld/helloworld
2773 INFO: checking COLLECT
2773 INFO: building COLLECT out00-COLLECT.toc
BTW:我的helloworld.py只包含声明print“hello world”。我尝试将#!/ usr / bin / python2.7放在顶部。
答案 0 :(得分:0)
检查系统变量LD_LIBRARY_PATH
的值echo $LD_LIBRARY_PATH
它可能指向错误的python库libpython2.7.so。
在我的情况下,我可以通过重置它来解决这个问题:
export LD_LIBRARY_PATH=