歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux教程 >> SUSE10 64位環境下配置Tkinter and Pmw

SUSE10 64位環境下配置Tkinter and Pmw

日期:2017/2/28 16:55:32   编辑:Linux教程

前言:需要將現有的話單程序移植到SUSE10下,並調用華為的話單加密算法。於是乎開始搭建調試環境,整個過程搭建10個小時之多,遂忙記錄下這個過程,避免後人循規蹈矩。

首先,在SUSE10,軟件管理工具中安裝:

tcl-devel

tk-devel

Package包,安裝完成後使用以下命令查看安裝是否成功:

linux89:/AntiSpam/software/linux/Python-2.5.2 # rpm -qa | grep tcl
tcl-devel-8.4.12-16.2
tcl-8.4.12-16.2
itcl-32bit-3.3-437.2
itcl-3.3-437.2
tclx-8.4-345.2
tcl-32bit-8.4.12-16.2

linux89:/AntiSpam/software/linux/Python-2.5.2 # rpm -qa | grep ^tk
tk-devel-8.4.12-14.12
tk-8.4.12-14.12
tk-32bit-8.4.12-14.12

在http://www.python.org/官方站點下載:

Source Distribution 筆者使用的版本為:Python-2.5.2.tar.bz2

Pmw 筆者使用的版本為:Pmw.1.3.2.tar.gz

使用WinSCP工具,使用root帳戶,上傳至任意目錄

開始安裝Python-2.5.2:

1、解壓Python編譯包:tar -jxvf Python-2.5.2.tar.bz2

2、進入Python路徑:cd Python-2.5.2

3、修改Python-2.5.2/Modules/Setup.dist文件,將以下部分開啟

# The _tkinter module.
#
# The command for _tkinter is long and site specific. Please
# uncomment and/or edit those parts as indicated. If you don't have a
# specific extension (e.g. Tix or BLT), leave the corresponding line
# commented out. (Leave the trailing backslashes in! If you
# experience strange errors, you may want to join all uncommented
# lines and remove the backslashes -- the backslash interpretation is
# done by the shell's "read" command and it may not be implemented on
# every system.

# *** Always uncomment this (leave the leading underscore in!):
_tkinter _tkinter.c tkappinit.c -DWITH_APPINIT \
# *** Uncomment and edit to reflect where your Tcl/Tk libraries are:
-L/usr/local/lib \
# *** Uncomment and edit to reflect where your Tcl/Tk headers are:
-I/usr/local/include \
# *** Uncomment and edit to reflect where your X11 header files are:
-I/usr/X11R6/include \
# *** Or uncomment this for Solaris:
-I/usr/openwin/include \
# *** Uncomment and edit for Tix extension only:
# -DWITH_TIX -ltix8.1.8.2 \
# *** Uncomment and edit for BLT extension only:
# -DWITH_BLT -I/usr/local/blt/blt8.0-unoff/include -lBLT8.0 \
# *** Uncomment and edit for PIL (TkImaging) extension only:
# (See http://www.pythonware.com/products/pil/ for more info)
# -DWITH_PIL -I../Extensions/Imaging/libImaging tkImaging.c \
# *** Uncomment and edit for TOGL extension only:
# -DWITH_TOGL togl.c \
# *** Uncomment and edit to reflect your Tcl/Tk versions:
# -ltk8.2 -ltcl8.2 \
# *** Uncomment and edit to reflect where your X11 libraries are:
# -L/usr/X11R6/lib \
# *** Or uncomment this for Solaris:
# -L/usr/openwin/lib \
# *** Uncomment these for TOGL extension only:
# -lGL -lGLU -lXext -lXmu \
# *** Uncomment for AIX:
# -lld \
# *** Always uncomment this; X11 libraries to link with:
# -lX11


4、使用make命令,進行編譯

5、使用sudo make install,進行安裝

6、確認Tkinter是否安裝成功:

QUOTE:
Step 1 - can _tkinter be imported?
Try the following command at the Python prompt:

>>> import _tkinter # with underscore, and lowercase 't'

If it works, go to step 2.
If it fails with "No module named _tkinter", your Python configuration needs to be modified to include this module (which is an extension module implemented in C). Do **not** edit Modules/Setup (it is out of date). You may have to install Tcl and Tk (when using RPM, install the -devel RPMs as well) and/or edit the setup.py script to point to the right locations where Tcl/Tk is installed. If you install Tcl/Tk in the default locations, simply rerunning "make" should build the _tkinter extension.
If it fails with an error from the dynamic linker, see above (for Unix, check for a header/library file mismatch; for Windows, check that the TCL/TK DLLs can be found).

Step 2 - can Tkinter be imported?
Try the following command at the Python prompt:

>>> import Tkinter # no underscore, uppercase 'T'

If it works, go to step 3.
If it fails with "No module named Tkinter", your Python configuration need to be changed to include the directory that contains Tkinter.py in its default module search path. You have probably forgotten to define TKPATH in the Modules/Setup file. A temporary workaround would be to find that directory and add it to your PYTHONPATH environment variable. It is the subdirectory named "lib-tk" of the Python library directory (when using Python 1.4 or before, it is named "tkinter").

檢查Python是否運行正常:

linux89:/AntiSpam/software/linux/Python-2.5.2 # python
Python 2.5.2 (r252:60911, Sep 18 2008, 19:17:58)
[GCC 4.1.2 20070115 (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>

linux89:/AntiSpam/software/linux/Python-2.5.2 # python
Python 2.5.2 (r252:60911, Sep 18 2008, 19:17:58)
[GCC 4.1.2 20070115 (SUSE Linux)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import _tkinter
>>>

Copyright © Linux教程網 All Rights Reserved