本文介绍了使用 pyinstaller 为 Solaris OS 分发 python 应用程序给我 subprocess.py 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据官方文档,pyinstaller 在 Solaris 下工作 PyInstaller 是一个将 Python 程序转换(打包)为独立可执行文件的程序,适用于 Windows、Linux、Mac OS X、Solaris 和 AIX"但到目前为止我被卡住了..

According to official docsite, pyinstaller works under Solaris "PyInstaller is a program that converts (packages) Python programs into stand-alone executables, under Windows, Linux, Mac OS X, Solaris and AIX" but so far I got stucked..

我在x86 Solaris 10u8系统下搭建了一个开发虚拟环境,然后安装了pyinstaller(带pip)和其他需要的模块...

I have built a development virtual environment under x86 Solaris 10u8 system and then installed pyinstaller (with pip) among other required modules...

$> pip list
distribute (0.7.3)
...
pycrypto (2.6.1)
PyInstaller (2.1)
setuptools (3.6)
wsgiref (0.1.2)

尝试从最基本的程序(test.py)制作一个 ELF 二进制文件:

Trying to make an ELF binary from the most basic program (test.py):

#!/usr/bin/env python
print "hello world"

我收到以下错误:

$> pyinstaller --onefile --clean test.py 
32 INFO: UPX is not available.
54 INFO: Processing hook hook-os
163 INFO: Processing hook hook-time
166 INFO: Processing hook hook-cPickle
238 INFO: Processing hook hook-_sre
356 INFO: Processing hook hook-cStringIO
453 INFO: Processing hook hook-encodings
469 INFO: Processing hook hook-codecs
...
2157 INFO: Analyzing test.py
2157 INFO: Hidden import 'codecs' has been found otherwise
2158 INFO: Hidden import 'encodings' has been found otherwise
2158 INFO: Looking for run-time hooks
Traceback (most recent call last):
File "/export/home/sistemas/virtualenvs/RadminPortal/bin/pyinstaller", line 9, in <module>
    load_entry_point('PyInstaller==2.1', 'console_scripts', 'pyinstaller')()
File "/export/home/sistemas/virtualenvs/RadminPortal/lib/python2.7/site-packages/PyInstaller/main.py", line 88, in run
    run_build(opts, spec_file, pyi_config)
File "/export/home/sistemas/virtualenvs/RadminPortal/lib/python2.7/site-packages/PyInstaller/main.py", line 46, in run_build
    PyInstaller.build.main(pyi_config, spec_file, **opts.__dict__)
File "/export/home/sistemas/virtualenvs/RadminPortal/lib/python2.7/site-packages/PyInstaller/build.py", line 1924, in main
    build(specfile, kw.get('distpath'), kw.get('workpath'), kw.get('clean_build'))
File "/export/home/sistemas/virtualenvs/RadminPortal/lib/python2.7/site-packages/PyInstaller/build.py", line 1873, in build
    execfile(spec)
File "/export/home/sistemas/fmartin/pruebas/test.spec", line 6, in <module>
    runtime_hooks=None)
File "/export/home/sistemas/virtualenvs/RadminPortal/lib/python2.7/site-packages/PyInstaller/build.py", line 446, in __init__
    self.__postinit__()
File "/export/home/sistemas/virtualenvs/RadminPortal/lib/python2.7/site-packages/PyInstaller/build.py", line 309, in __postinit__
    self.assemble()
File "/export/home/sistemas/virtualenvs/RadminPortal/lib/python2.7/site-packages/PyInstaller/build.py", line 677, in assemble
    self._check_python_library(binaries)
File "/export/home/sistemas/virtualenvs/RadminPortal/lib/python2.7/site-packages/PyInstaller/build.py", line 713, in _check_python_library
    python_lib = bindepend.get_python_library_path()
File "/export/home/sistemas/virtualenvs/RadminPortal/lib/python2.7/site-packages/PyInstaller/bindepend.py", line 722, in get_python_library_path
    python_libname = findLibrary(name)
File "/export/home/sistemas/virtualenvs/RadminPortal/lib/python2.7/site-packages/PyInstaller/bindepend.py", line 657, in findLibrary
    return os.path.join(dir, getSoname(lib))
File "/export/home/sistemas/virtualenvs/RadminPortal/lib/python2.7/site-packages/PyInstaller/bindepend.py", line 665, in getSoname
    m = re.search(r'\s+SONAME\s+([^\s]+)', compat.exec_command(*cmd))
File "/export/home/sistemas/virtualenvs/RadminPortal/lib/python2.7/site-packages/PyInstaller/compat.py", line 210, in exec_command
    return subprocess.Popen(cmdargs, stdout=subprocess.PIPE).communicate()[0]
File "/opt/csw/lib/python2.7/subprocess.py", line 709, in __init__
    errread, errwrite)
File "/opt/csw/lib/python2.7/subprocess.py", line 1326, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

如果我已经安装了所有需要的python库包并设置了方便的路径,我还需要什么?

What else could I need if I have already installed all python library needed packages and set up the convenient paths?

$> pkginfo | grep -i python
application CSWlibpython2-6-1-0              libpython2_6_1_0 - Python shared library (2.6)
application CSWlibpython2-7-1-0              libpython2_7_1_0 - A high-level scripting language., libpython2.7.so.1.0
application CSWpy-pip                        py_pip - A Python easy_install replacement
application CSWpy-setuptools                 py_setuptools - Distribution Utiltiies for Python
application CSWpython                        python - A high-level scripting language, 2.6 series
application CSWpython-dev                    python_dev - Development Files for Python
application CSWpython27                      python27 - A high-level scripting language, 2.7 series
application CSWpython27-dev                  python27_dev - Development Files for Python
...

$> echo $LD_LIBRARY_PATH
/opt/csw/lib/python2.7:/opt/csw/lib

$> echo $PATH
/usr/bin:/usr/local/bin:/opt/csw/gcc4/bin:/usr/sfw/bin:/opt/csw/bin

提前致谢!!

推荐答案

由于 Solaris 属于实验端口类别,Pyinstaller 可能无法正常使用 pip 安装它.我建议克隆 Pyinstaller 的 github 官方存储库.

Since Solaris is under Experimental ports category Pyinstaller might not work by using pip to install it as usual. I would recommend to clone the github official repository for Pyinstaller.

参见:https://github.com/pyinstaller/pyinstaller

# /opt/csw/bin/git clone https://github.com/pyinstaller/pyinstaller.git

此外,在使用实验端口之前必须构建 PyInstaller 引导加载程序,因此请确保您的 LD_LIBRARY_PATH 包含所有需要的路径并运行以下命令:

Moreover, PyInstaller bootloader must be build before using experimental ports so ensure your LD_LIBRARY_PATH contains every needed path and run the following command:

# export PATH=${PATH}:/opt/csw/bin:/opt/csw/gcc4/bin:/usr/ccs/bin
# export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/opt/csw/lib/python2.7:/opt/csw/lib:/usr/local/lib
# python2.7 ./waf configure build install
SunOS-32bit detected
Checking for program gcc or cc           : /opt/csw/bin/gcc
Checking for program cpp                 : /opt/csw/bin/cpp
Checking for program ar                  : /usr/ccs/bin/ar
Checking for program ranlib              : /usr/ccs/bin/ranlib
Checking for gcc                         : ok 
Checking for library dl                  : yes
Checking for library z                   : yes
Checking for function readlink           : yes
Checking for flags -m32                  : yes
'configure' finished successfully (1.690s)
Waf: Entering directory `/export/home/sistemas/pyinstaller/bootloader/build'
[ 1/40] cc: linux/getpath.c -> build/debug/linux/getpath_1.o
[ 2/40] cc: common/pyi_global.c -> build/debug/common/pyi_global_1.o
[ 3/40] cc: common/pyi_launch.c -> build/debug/common/pyi_launch_1.o
...
'install' finished successfully (0.140s)

然后,作为非 root 用户,您已准备好构建您的 Python.

Then, as non-root user, you are ready to build your pythons.

这篇关于使用 pyinstaller 为 Solaris OS 分发 python 应用程序给我 subprocess.py 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-10 16:47