rhel5.5 搭建pyinstaller环境

来源:互联网 发布:booking.it 编辑:程序博客网 时间:2024/06/03 20:03

rhel5.5 搭建pyinstaller环境

1.python和pyinstaller环境搭建(redhat5.5)

1.1 从python官网下载python2.7.12。

1.2 安装:https://www.python.org/ftp/python/2.7.12/Python-2.7.12.tar.xz

  xz  -d Python-2.7.12.tar.xz

  tar -xf Python-2.7.12.tar

  cd Python-2.7.12

  . /configure --enable-shared --prefix=/tmp/python2.7 (注意:一定要加上--enable-shared参数,允许build python动态库。否则,pyinstaller会报:找不到模块。IOError:  Python     library not found: libpython2.7mu.so.1.0, libpython2.7.so.1.0, libpython2.7m.so.1.0)

  make

  make install

1.3 安装setuptool,以便使用setup安装包点击打开链接。

 tar -zxf setuptoos.tar.gz

  cd  setuptoos

  export PATH=/tmp/python2.7:$PATH  (方便可以直接调用最新的python命令)

  export LD_LIBRARY_PATH=/tmp/python2.7/lib/

  python2.7 setup.py install --prefix=/tmp/python2.7/  (将pip安装到最新的python中)


1.4 安装pip,下载pip点击打开链接。

  tar -zxf pip-9.0.1.tar.gz

  cd  pip-9.0.1

  export PATH=/tmp/python2.7:$PATH  (方便可以直接调用最新的python命令)

  export LD_LIBRARY_PATH=/tmp/python2.7/lib/

  python2.7 setup.py install --prefix=/tmp/python2.7/  (将pip安装到最新的python中)

1.5安装pyinstaller

  pip install pyinstaller

至此就安装完成了!

2. pyinstaller打包可执行文件。

1.打成单个可执行文件:

pyinstaller -F test.py  (test.py为自己所需要打成的可执行文件的源码)

2.打成包,包中包含动态库和可执行文件。

pyinstaller -D test.py

3.部分参数解释:

-i 跟程序的ico文件。

-w 非console程序。

3.安装python过程中出现的问题。

1.在编译python动态库时即(--enable-shared参数),会出现:缺少库的问题:

Python build finished, but the necessary bits to build these modules were not found:
_tkinter           bsddb185           dl              
imageop            sunaudiodev                        
To find the necessary bits, look in setup.py in detect_modules() for the module's name.

这个问题在多个python版本中编译都会出现,这个问题可以根据自身实际需要来安装需要的库。

2.pyinstaller和自己编译安装python启动都需要加载自身动态链接库,所以,在使用之前请export以下环境变量:

export LD_LIBRARY_PATH=/tmp/python2.7/lib/

1 0
原创粉丝点击