TKinter in a Virtualenv

前端 未结 9 1720
北荒
北荒 2020-12-05 00:27

Trying to run python code with TKinter-based widgets from a virtualenv.

    user@computer:~/myproject$ env/bin/python Python
    2.7.3 (default, Sep 26 2012,         


        
9条回答
  •  死守一世寂寞
    2020-12-05 01:05

    Set the environment variable TCL_LIBRARY in your activate script. On Windows (Python 2.7 with Tcl 8.5), just add this line to Scripts\activate.bat:

    set "TCL_LIBRARY=C:\Python27\tcl\tcl8.5"
    

    @Jasper van den Bosch's edit: On Ubuntu, the modification to the script activate is the following:

    TK_LIBRARY=/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/site-packages/PIL:/usr/lib
    TKPATH=/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/site-packages/PIL:/usr/lib 
    TCL_LIBRARY=/usr/lib 
    export TCL_LIBRARY TK_LIBRARY TKPATH
    

    The reference of this can be found on this question on askubuntu

提交回复
热议问题