Redhat7.2安装Python3.5.6支持tkinter开发

1、修改Python3.5.6源码包

Python-3.5.6\Modules\Setup.dist

找到下面这些行,去掉屏蔽
_tkinter _tkinter.c tkappinit.c -DWITH_APPINIT
-L/usr/local/lib
-I/usr/local/include
-I/usr/X11R6/include
-ltk8.6 -ltcl8.6 \ #m默认是8.2
-L/usr/X11R6/lib
-lX11

2、Python3.5.6安装
./configure --prefix=/home/imhqq/env/python3.5.6 --enable-optimazations --enable-shared CFLAGS=-fPIC
make
make install

3、python动态库拷贝到/usr/local/lib
cp /home/imhqq/env/python3.5.6/lib/libpython3.5m.so /usr/local/lib/libpython3.5m.so
cp /home/imhqq/env/python3.5.6/lib/libpython3.5m.so.1.0 /usr/local/lib/libpython3.5m.so.1.0
cp /home/imhqq/env/python3.5.6/lib/libpython3.so /usr/local/lib/libpython3.so

4、指定LD_LIBRARY_PATH
[root@localhost Chap06]# vi ~/.bash_profile

.bash_profile

Get the aliases and functions

if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

User specific environment and startup programs

PATH=HOME/bin
export PATH
LD_LIBRARY_PATH=/usr/local/lib
export LD_LIBRARY_PATH
[root@localhost Chap06]# source ~/.bash_profile_

5、使用virtualenv创建python3.5.6开发环境
[root@localhost python_test]# virtualenv -p /home/imhqq/env/python3.5.6/bin/python3.5 /home/imhqq/pyenv/python3.5.6
Running virtualenv with interpreter /home/imhqq/env/python3.5.6/bin/python3.5
Using base prefix '/home/imhqq/env/python3.5.6'
New python executable in /home/imhqq/pyenv/python3.5.6/bin/python3.5
Not overwriting existing python script /home/imhqq/pyenv/python3.5.6/bin/python (you must use /home/imhqq/pyenv/python3.5.6/bin/python3.5)
Installing setuptools, pip, wheel...done.

6、进入python3.5.6开发环境,检测tkinter是否安装
[root@localhost python_test]# source /home/imhqq/pyenv/python3.5.6/bin/activate

(python3.5.6) [root@localhost python_test]# python
Python 3.5.6 (default, Jan 20 2019, 19:46:13)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-36)] on linux
Type "help", "copyright", "credits" or "license" for more information.

import tkinter

7、ssh登陆自动执行脚本:
vi ~/. bashrc

.bashrc

User specific aliases and functions

alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

Source global definitions

if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

cd /home/imhqq
source pyenv/python3.5.6/bin/activate
cd python_test/tkinter/
~
source ~/.bashrc

你可能感兴趣的:(Redhat7.2安装Python3.5.6支持tkinter开发)