Installing Python 3.12 with custom TCL/TK on RHEL 7

139 views Asked by At

I am trying to build Python 3.12 with TCL/TK on RHEL 7.

I have 0 root privileges. My system build is HORRIBLY outdated. I have no control over this and cannot update/use package installers, which is why I've gone through this 'compiling from source' endeavor.

After digging around I found that there WAS a configure option in the past for --with-tcltk... but those options were removed. After looking in the whatsnew, I found that you can specify the custom locations using the envvars TCLTK_CFLAGS and TCLTK_LIBS. My tcl/tk installations are not in the same directory, they are under $HOME/.../tcl8.6 and $HOME/.../tk8.6 respectively. (I'm using abs path on the envvars)

I know I'm close, but after building using these variables I still can't import tkinter after compiling python3.12.1 on RHEL 7.

I have not found any information as to how to use those variables, which paths I need to specify/what is necessary or any examples of how to do this.

1

There are 1 answers

0
L.Ceja On

OK, found the answer to anyone who may have a similar issue. I was on the right track, but I missed -tcl8.6 and -tk8.6 options on the TCLTK_LIBS envvar.

Here is a link to the source of the post that helped me figure this out: Solution

I placed all the settings onto a script.

***In order to load tkinter, you'll need to export LD_LIBRARY_PATH with the tcl/tk/ssl library directories before starting python. Exporting this env var screws with a program that out workstations rely on, so I need to do this everytime I load python.

#!/bin/bash

#My source locations; yours will differ
bin_path="$HOME/bin"
src_path="/mnt/netapp_data/bin/src"

python_source="$bin_path/src/sourcefiles/Python-3.12.1"
python_dest="$bin_path/src/python/python3.12"

ssl="$src_path/openssl"
tk="$src_path/tk8.6"
tcl="$src_path/tcl8.6"

# Need to export these vars; need '-L{lib_dir} -l{lib}' per library apparently
export LD_LIBRARY_PATH=$tcl/lib:$tk/lib:$ssl/lib
export TCLTK_CFLAGS="-I$tcl/include -I$tk/include"
export TCLTK_LIBS="-L$tcl/lib -ltcl8.6 -L$tk/lib -ltk8.6"

#This is pretty standard after setting up the env vars
cd $python_source
./configure --prefix=$python_dest --with-openssl=$ssl --with-ensurepip=install
make -j4
make install