[Python] Install tkinter and the Python interpreter locally

Discussão em 'Python' iniciado por Stack, Julho 13, 2025.

  1. Stack

    Stack Membro Participativo

    I work with Linux on a service. And I don't have the root privilege. I installed the python-3.2.3 locally to "/home/sam/install_sam". when I import the tkinter module. I get the following error:

    ImportError: No module named _tkinter, please install the python-tk package


    I know I need to install the Tkinter module. Because I don't have the root privilege. I can't use like the following commands:

    apt-get install python-tk
    sudo apt-get install python-tk


    And I search on Google. I get tcl/tk from here. I install them use the following commands.

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

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

    cd ~/Downloads/Python3.2.3/
    export LD_LIBRARY_PATH=/home/sam/install_sam/tcl/lib:/home/sam/install_sam/tk/lib
    export LD_RUN_PATH=/home/sam/install_sam/tcl/lib:/home/sam/install_sam/tk/lib
    ./configure --prefix=/home/sam/install_sam/python
    make
    make install


    I still got an error: INFO: Can't locate Tcl/Tk libs and/or headers. How should I configure the tcl/tk for the Python interpreter?

    Continue reading...

Compartilhe esta Página