HOWTO: Python 2.3 on Fedora Core 1 Linux

Discussion in 'Python' started by Logan, Nov 26, 2003.

  1. Logan

    Logan Guest

    Several people asked me for the following HOWTO, so I decided to
    post it here (though it is still very 'alpha' and might contain
    many (?) mistakes; didn't test what I wrote, but wrote it - more
    or less - during my own installation of Python 2.3 on Fedora Core 1
    Linux for a friend of mine).

    Anyway, HTH, L.



    HOWTO: Install a separate Python 2.3.2 on Fedora Core 1 Linux without
    removing the preinstalled Python 2.2.3 which is needed by many
    of the Fedora/RedHat configuration scripts.


    Table of Contents:

    I. Some reasons for doing this

    II. Warning

    III. Dependencies

    IV. About the 'new' Python

    V. Installation
    - Installing Tcl/Tk 8.4
    - Installing Python 2.3.2 (final)
    - Installing the libxml2/libxslt Python bindings
    - Installing PyGTK (Python bindings for GTK+ 2.x)
    - Installing wxPython with wxGTK (Python bindings for wxWindows)

    VI. Test the Installation

    Appendix A: Python Installation with Tkinter - edit: Modules/Setup.dist

    =========================================================================

    I. Some reasons for doing this:

    (1) You want to use Python 2.3.
    (2) Python 2.2 (as preinstalled by Fedora) is a mess; e.g. Tkinter
    (as provided by Fedora) does not work (UCS-2/UCS-4 problem with
    Python - Tkinter - Tcl/Tk).
    (3) Python 2.2 (as preinstalled by Fedora) uses a lot of 3rd party
    packages (s. /usr/lib/python2.2/site-packages). Installing newer
    or older (sometimes necessary) versions of these packages can cause
    trouble with the Fedora/RedHat configuration scripts. Some other 3rd
    party packages might also have or cause problems with one or more of
    the preinstalled packages (e.g. XML stuff).
    (4) You want to know exactly what kind of Python (compiler options) and
    which 3rd party packages you are using.
    (5) etc. etc. :)

    =========================================================================

    II. Warning:

    Be aware that it is always risky to install new software; maybe you will
    destroy your whole system, loose data etc. This document comes with no
    warranty at all; following the instructions in this document is something
    you have to do at your own risk!

    Recommendation: don't follow the instructions in this document but read
    the documentation which comes with the distributions which are described
    in this document. (A good reason for doing this: installation procedures
    are not written in stone but often change with new releases.)

    =========================================================================

    III. Dependencies:

    Since you will have to compile everything from source, you have to make
    sure first that all the necessary RPMs for doing this are installed on
    your system:

    - gcc, gcc-c++ (C/C++ compiler)
    - XFree86-devel
    - libxml2(-devel), libxslt(-devel) if you want to use libxml2/libxslt
    - ... (?)

    Use 'rpm -qi ...' to check this.

    =========================================================================

    IV. About the 'new' Python:

    On Fedora, Python is installed in /usr/bin, /usr/lib etc. The same holds
    e.g. for Tcl/Tk (which is needed by Tkinter) etc. etc.

    So what you can do is: install the new Python (and related stuff) in the
    /usr/local/bin, /usr/local/lib etc. branch.

    The only problem is that you will end up with two 'python' commands (one
    in /usr/bin for Fedora's Python 2.2 and one in /usr/local/bin for the new
    Python 2.3). You have to delete the one in /usr/local/bin and use a tiny
    start-up script 'py' instead (s. further below).

    =========================================================================

    V. Installation:


    Installing Tcl/Tk 8.4:
    ----------------------

    Fedora Core 1 comes with Tcl/Tk 8.3 (actually: 8.3.5). If you want to use
    Tkinter with your new python, I recommend to install Tcl/Tk 8.4 first (in
    the /usr/local branch, where everything related to the new Python goes).

    tarballs: tcl8.4.4-src.tar.gz, tk8.4.4-src.tar.gz

    - get the above tarballs from http://www.tcl.tk and untar them with
    'tar -xzf tcl8.4.4-src.tar.gz' resp. 'tar -xzf tk8.4.4-src.tar.gz'

    - change (cd) to the 'unix' subdir of the newly created dir with the
    Tcl distribution and do the usual:

    ./configure
    make
    make install

    - change (cd) to the 'unix' subdir of the newly created dir with the
    Tk distribution and do the usual:

    ./configure
    make
    make install

    (The above will install Tcl/Tk in /usr/local/lib etc.)


    Installing Python 2.3.2 (final)
    -------------------------------

    tarball: Python-2.3.2.tgz

    - get the above tarball from http://www.python.org and untar it

    - if you want to use Tkinter, edit the file 'Setup.dist' in the subdir
    'Modules' of the newly created dir with the Python distribution (see
    Appendix A for details)

    - type:

    LD_LIBRARY_PATH=/usr/local/lib
    export LD_LIBRARY_PATH

    (Otherwise, lbitk8.4.so in /usr/local/lib will not be found by 'make'.)

    - type (in the newly created directory with the Python distribution):

    ./configure
    make
    make install

    - remove (rm) /usr/local/bin/python

    (Otherwise /usr/bin/python (Python 2.2!) will not work any more.)

    - now you will need a start-up script for Python;
    create a file /usr/local/bin/py with the following content:

    #!/bin/bash
    LD_LIBRARY_PATH=/usr/local/lib
    export LD_LIBRARY_PATH
    /usr/local/bin/python2.3 $1 $2 $3 $4 $5 $6 $7 $8 $9

    (This is necessary, because Python - when invoked via 'python2.3' does
    not find libtk8.4.so otherwise.)

    (You could also use LD_LIBRARY_PATH permanently (not recommended), use
    a symbolic link in /usr/lib or use 'ldconfig'; but the above solution
    works as long as you start your Python scripts with 'py <script-name>'
    and not via the shebang line #!/usr/bin/env python; (you can still use
    the shebang line #!/usr/bin/env py).)


    Installing the libxml2/libxslt Python bindings
    ----------------------------------------------

    (This is clearly optional; I use them all the time, thus they are in
    this document.)

    tarball: libxml2-python-2.5.11.tar.gz

    (The version must *exactly* match the version of the installed libxml2
    library; check this with 'rpm -qi libxml2'.)

    - get the above tarball from ftp://xmlsoft.org/python/ and untar it

    - type (in the newly created directory with the libxml2 distribution):

    py setup.py install

    (Important: use 'py' here (and not 'pyhton'); otherwise the package
    gets installed in the 'site-packages' subdir of Python 2.2 and not
    in the 'site-packages' subdir of the new Python 2.3.)

    (The installation will trigger a 'Deprecation' warning: "xmllib should
    not be used anymore; use xml.sax instead"; simply ignore this.)


    Installing PyGTK (Python bindings for GTK+ 2.x)
    -----------------------------------------------

    (This is clearly optional; I use it, thus it is in this document.)

    tarball: pygtk-2.0.0.tar.gz

    - get the tarball from ftp://ftp.gtk.org/pub/gtk/python/v2.0/
    and untar it

    - type:

    PYTHON=/usr/local/bin/python2.3
    export PYTHON

    (Otherwise PyGTK goes into the 'site-packages' subdir of Python 2.2
    and not in the 'site-packages' subdir of the new Python 2.3.)

    - type (in the newly created subdir with the PyGTK distribution):
    ./configure
    make
    make install


    Installing wxPython with wxGTK (Python bindings for wxWindows)
    --------------------------------------------------------------

    (This is clearly optional; I use it, thus it is in this document.)

    tarball: wxPythonSrc-2.4.2.4.tar.gz

    (s. furter below for optional tarballs with demos, documentation etc.)


    - get the tarball from http://www.wxpython.org and untar it

    - change (cd) to the newliy created directory with the wxPython
    distribution

    - type:

    export WXPREF=/usr/local/lib/wxPython

    - create a 'build' dir and use it; type:

    mkdir build
    cd build

    - first, we have to install wxGTK, since wxPython uses GTK+ 2.x on Linux;
    type (we use \ for 'line continuation'; type everything on one line):

    ../configure --with-gtk \
    --prefix=$WXPREF \
    --enable-rpath=$WXPREF/lib \
    --with-opengl \
    --enable-geometry \
    --enable-optimise \
    --enable-debug_flag \
    --with-libjpeg=builtin \
    --with-libpng=builtin \
    --with-libtiff=builtin \
    --with-zlib=builtin \
    --enable-gtk2 \
    --enable-unicode \

    (This will configure wxGTK for GTK 2.x with Unicode. Moreover, some
    'builtin' image libraries are used and not the image libraries of
    your system. See the file 'README.1st.txt' in the distribution for
    further information.)

    - type:

    make
    make install

    - now we can install wxPython itself;
    type (again, type everything on one line (without the '\')):

    cd ../wxPython
    py setup.py \
    WX_CONFIG=$WXPREF/bin/wx-config \
    WXPORT=gtk2 UNICODE=1 \
    build install

    (Use 'py' in the above; not 'python'! That will tell wxPython where
    to install the package ('site-packages' of Python 2.3) and for which
    version of Python to build for.)

    - optionally (but highly recommended): install the wxPython demo (incl.
    the samples) and the wxWindows documentation:

    tarballs: wxPythonDemo-2.4.2.4.tar.gz, wxPythonDocs-2.4.2.4.tar.gz

    - get the tarballs from http://www.wxpython.org and untar them
    - move (mv) the subdirs of the newly created dir with the demo, samples
    and docs to /usr/local/lib/wxPython

    =========================================================================

    VI. Test the Installation

    Open a new console (*not* as user root; old consoles might not find the
    new commands etc. properly). Then try out the following:

    - Python 2.2 still OK?

    start a python shell with 'python'
    the shell should tell you that you are running Python 2.2

    (Under Linux, you can quit a python shell with 'Ctrl-d'.)

    (You could also try to run one of the 'redhat-config-...'
    scripts; (depends on which of these scripts are installed
    on your system).)


    - Python 2.3 OK?

    start a python shell with 'py'
    the shell should tell you that you are running Python 2.3


    - libxml2/libxslt Python bindings OK?

    start a python shell with 'py'

    type: import libxml2
    type: import libxslt

    both should work without any errors or warnings


    - Tkinter (Tcl/Tk) OK?

    type: py /usr/local/lib/python2.3/lib-tk/Tkinter.py

    a Tk window should open telling you that you are running Tk 8.4


    - PyGTK OK?

    run (with the 'py' command) any of the examples in the subdirs of:

    /usr/share/doc/pygtk2-2.0.0/examples

    (e.g.: py /usr/share/doc/pygtk2-2.0.0/examples/pygtk-demo/demos/menu.py
    should pop up a window with menu examples)


    - wxPython OK?

    type: py /usr/local/lib/wxPython/demo/demo.py

    this should start the wxPython demo

    (
    to view the wxWindows documentation, do the following:

    type: cd /usr/local/lib/wxPython/docs/
    py viewdocs.py
    )

    =========================================================================

    Appendix A:

    Python Installation with Tkinter - edit: Modules/Setup.dist

    The Modules/Setup.dist file must be modified in the following way:

    # -- BEGINNING OF CHANGES --

    # 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.4 -ltcl8.4 \
    # *** 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

    # -- END OF CHANGES --


    --
    mailto: logan@phreaker(NoSpam).net
     
    Logan, Nov 26, 2003
    #1
    1. Advertising

  2. Logan <> wrote in message news:<>...
    > Several people asked me for the following HOWTO, so I decided to
    > post it here (though it is still very 'alpha' and might contain
    > many (?) mistakes; didn't test what I wrote, but wrote it - more
    > or less - during my own installation of Python 2.3 on Fedora Core 1
    > Linux for a friend of mine).
    >


    Thank you very much for this! (I've ordered Fedora CDs just yesterday ...)

    Michele
     
    Michele Simionato, Nov 26, 2003
    #2
    1. Advertising

  3. Logan

    Logan Guest

    On Wed, 26 Nov 2003 03:51:36 +0100, Logan wrote:
    >
    > Installing wxPython with wxGTK (Python bindings for wxWindows)
    >
    >
    > ... ... ...
    >
    >
    > ../configure --with-gtk \
    > --prefix=$WXPREF \
    > --enable-rpath=$WXPREF/lib \
    > --with-opengl \
    > --enable-geometry \
    > --enable-optimise \
    > --enable-debug_flag \
    > --with-libjpeg=builtin \
    > --with-libpng=builtin \
    > --with-libtiff=builtin \
    > --with-zlib=builtin \
    > --enable-gtk2 \
    > --enable-unicode \
    >


    There seems to be a problem with wxPython on Fedora Core 1 Linux,
    if you install it as described above (s. main posting). E.g. when
    right clicking on a TextCtrl, no popup-window appears but the
    script crashes (seg fault).

    (More on this: s. the mailing list for wxPython.)

    To avoid this (i.e. the seg faults), use the following to
    configure wxGTK (instead of the above):

    ../configure --prefix=$WXPREF \
    --enable-rpath=$WXPREF/lib \
    --with-opengl \
    --enable-geometry \
    --enable-optimise \
    --enable-gtk2 \
    --enable-unicode \

    L.

    --
    mailto: logan@phreaker(NoSpam).net
     
    Logan, Nov 29, 2003
    #3
  4. Logan

    b0x Guest

    hey, thx alot for this topic,i had so many problems in installing tkinter , google didnt help me this time, but your toipc did :0) ..
     
    b0x, Mar 2, 2004
    #4
  5. Logan

    b0x Guest

    hey, thx alot for this topic,i had so many problems in installing tkinter , google didnt help me this time, but your toipc did :0) ..
     
    b0x, Mar 2, 2004
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Thomas
    Replies:
    1
    Views:
    398
    Rob Renaud
    Nov 19, 2003
  2. Bill
    Replies:
    2
    Views:
    364
  3. Replies:
    0
    Views:
    309
  4. bobmon
    Replies:
    2
    Views:
    346
    bobmon
    Feb 25, 2007
  5. John Nagle
    Replies:
    15
    Views:
    521
    John J. Lee
    Mar 11, 2007
Loading...

Share This Page