Install tkinter and python locally

sudo apt-get install tcl-dev tk-dev

worked for me, although I ended up pulling a docker image and using that instead.


Finally. I install tcl/tk and python in a same path. It can work now. the commands as follow:

cd ~/Downloads/tcl8.5.11/unix
./configure --prefix=/home/sam/install_sam/python3
make
make install

cd ~/Downloads/tk8.5.11/unix
./configure --prefix=/home/sam/install_sam/python3
            --with-tcl=/home/sam/Downloads/tcl8.5.11/unix
make
make install

export LD_LIBRARY_PATH=/home/sam/install_sam/python3/lib
cd ~/Downloads/Python3.2.3/3
./configure --prefix=/home/sam/install_sam/python3 
make
make install

someone can tell me how to config the tcl/tk for python in the first way(mentioned in the question). I'll appreciate it


Use CPPFLAGS environment variable to set the include directories for tcl and tk before building Python 3. This has worked for me.

export CPPFLAGS="-I/home/sam/install_sam/tcl/include -I/home/sam/install_sam/tk/include"