rhel5.5 搭建pyinstaller环境

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
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值