To be able to use idle with my virtualenv python, I created an idle script
#!/myvirtualenv/python
from idlelib.PyShell import main
if __name__ == '__main__':
main()
in the bin/ of my virtualenv but it complains abou开发者_运维知识库t not being able to find Tkinter.
** IDLE can't import Tkinter. Your Python may not be configured for Tk. **
I checked and Tkinter can be imported in the regular python2.7.1 but I can't import Tkinter from my virtualenv python. How can I make Tkinter available to my virtualenv python ( I have to use no site-packages with the virtualenv for an other reason) Thanks
One simple solution is to copy the tcl folder from your original python installation to the virtual environment. For example, on my machine I did the following:
C:\> virtualenv t:\env\myenv
C:\> xcopy c:\python27\tcl t:\env\myenv\tcl /e /i /k
I'm currently using IDLE in a few Virtual Environments but my script to start it up looks like below. This works for me whether I created my environment using --no-site-packages option or not. For some reason I had to put the full path to my virtual python in the header of the script.
#!/home/steve/virt_idle/bin/python
from idlelib.PyShell import main
if __name__ == '__main__':
main()
精彩评论