一、 下载python3
参考链接:
<u>https://www.jianshu.com/p/8b4d52869d86</u>
<u>https://jingyan.baidu.com/article/afd8f4deb393fa34e386e910.html</u>
<u>https://blog.csdn.net/jeffery0207/article/details/79774567</u>
1. 在root目录下执行命令
wget <u>https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz</u>
2.[root@ ~]# tar -zxvf Python-3.6.3.tgz
3.[root@ ~]# cd Python-3.6.3
4.Centos7的依赖
[root@ Python-3.6.3]# yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make –y
Centos6的依赖 两个
[root@Python-3.6.3]# yum install gcc patch libffi-devel python-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel –y
[root@ Python-3.6.3]# yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel readline-devel.x86_64 -y
5.[root@ Python-3.6.3]# ./configure prefix=/usr/local/python3
6.Make &make install
二、链接
1.[root@ Python-3.6.3]# ln -s /usr/local/python3/bin/python3 /usr/bin/python3
2. [root@ Python-3.6.3]# ll/usr/bin/py*
3.[root@ Python-3.6.3]# vim /usr/bin/yum 不确定是否执行,
#!/usr/bin/python 修改为 #!/usr/bin/python2
4.[root@ Python-3.6.3]# ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3
5.[root@ Python-3.6.3]# pip3 install --upgrade pip
三、默认用python3
1.[root@ Python-3.6.3]# mv /usr/bin/python /usr/bin/python.bak
2.[root@ Python-3.6.3]# ln -s /usr/local/python3/bin/python3.6 /usr/bin/python
可以输入python验证是什么版本,或者用python –V 验证版本
一、 安装Pyinstaller
1. 把pyinstaller-3.5.tar.gz下载到root目录下
<u>http://www.pyinstaller.org/downloads.html</u>
2. [root@ ~]# tar -zxvf PyInstaller-3.5.tar.gz
3. python setup.py install
4.[root@ PyInstaller-3.5]# python3 pyinstaller.py -F test.py test.py为打包文件,以下为报错。
解决:<u>https://www.cnblogs.com/jerryzh/p/10937905.html</u>
Cd /root/Python-3.6.3/
./configure --prefix=/usr/local/python36 --enable-shared --with-ssl
make
make install
五、输入python,页面报错
解决:<u>https://blog.csdn.net/df0128/article/details/89446507</u>
[root@Python-3.6.3]# cp libpython3.6m.so.1.0 /usr/local/ lib64/
[root@ Python-3.6.3]# cp libpython3.6m.so.1.0 /usr/lib/
[root@ Python-3.6.3]# cp libpython3.6m.so.1.0 /usr/lib64/
六、开始打包
Cd /root/PyInstaller-3.5/
[root@PyInstaller-3.5]# python3 pyinstaller.py -F test.py
会在/root/PyInstaller-3.5/生成一个test的文件夹,在test文件夹下有dist文件夹,dist文件夹下就会有test二进制文件。