课程设计:缓冲区溢出
虚拟机:Ubuntu12.04
实现封装python为可执行文件
安装python3和pip3
cd /usr/local/src
wget https://www.python.org/ftp/python/3.5.1/Python-3.5.1.tar.xz #python3.5.1版或者自己先去下载好压缩包
xz -d Python-3.5.1.tar.xz #解压
tar xvf Python-3.5.1.tar #解压
cd Pyton-3.5.1
sudo mkdir /usr/local/python3
sudo chmod 777 /usr/local/python3/
./configure --prefix=/usr/local/python3 --enable-shared #配置python3.5安装路径
sudo make #编译
sudo make install #安装
如果make时有如下语句:
Python build finished, but the necessary bits to build these modules were not found:
_bsddb _curses _curses_panel
_sqlite3 _ssl _tkinter
bsddb185 bz2 dbm
dl gdbm imageop
readline sunaudiodev zlib
To find the necessary bits, look in setup.py in detect_modules() for the module's name.
可以通过如下语句
sudo apt-get install zlib-dev bzip2-dev openssl-dev ncurses-dev sqlite-dev readline-dev tk-dev
sudo apt-get install --reinstall zlibc zlib1g zlib1g-dev
sudo apt-get install libssl-dev
或者参考这些博客安装之后重新编译:
Python build finished, but the necessary bits to build these modules were
Python3 ssl模块不可用的问题
sudo make install之后返回如下信息即为成功:
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-7.1.2 setuptools-18.2
之后开始设置软链接:
cd /usr/bin
sudo ln -s /usr/local/python3/bin/python /usr/bin/python3 #名字个人喜欢
sudo ln -s /usr/local/python3/bin/pip /usr/bin/pip3
python3 --version #查看版本
pip3 --version #看到输出路径来自python3.5的就对了
安装pyinstaller
pip install pyinstaller
直到返回这个结果才算成功
Successfully installed pyinstaller-x.x.x
x.x.x代表版本号
此时安装python的bin目录下应该多了一个pyinstaller的可执行文件,到此就完全成功安装了,如果不成功的话就重复几次,主要看系统的提示,要求更新就赶紧更新。
之后要开始设置软连接:
cd /usr/bin
sudo ln -s /usr/local/python/bin/pyinstaller /usr/bin/pyinstaller
pyinstaller --version #查看版本
然后就可以开始
pyinstaller -F XXX.py
如果成功的话就可以离开了
如果报错
If you're building Python by yourself, please rebuild your Python with '--enable-shared'
那么就先转到python安装包的目录,然后:
sudo ./configure --prefix=你的python路径 --enable-shared
sudo make
sudo make install
如果报错
error while loading shared libraries: libpython3.5m.so.1.0: cannot open shared object file:
这样解决
cd/etc/ld.so.conf.d
sudo vim python3.conf
编辑 添加库文件路径 /你的路径/Python3/lib
:wq
sudo dconfig
参考博客
Python PyInstaller安装和使用教程(详解版)
python3: error while loading shared libraries: libpython3.5m.so.1.0: cannot open shared object file
ubuntu12.04安装python3.5及pip3和setuptools