user@computer:~/myproject$ env/bin/python Python
2.7.3 (default, Sep 26 2012, 21:51:14) [GCC 4.7.2] on linux2 Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 42, in <module>
raise ImportError, str(msg) + ', please install the python-tk package' ImportError: No module named _tkinter, please install the python-tk package
如何在虚拟环境中正确安装TK?
TKinter
并不了解,但我曾经遇到过类似的问题,尝试在virtualenv
中运行wxPython
和pyGTK
。由于它们严重依赖共享库,我从未能找到令人满意的安装方法。除非你需要系统站点包之外的某个特定版本的Tkinter
,否则我建议只需创建一个带有--system-site-packages
标志的virtualenv
,然后本地安装您需要的任何其他特定模块即可。 - ali_m