python virtualenv idle and tkinter issue
Asked Answered
U

2

7

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 about 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

Undemonstrative answered 3/5, 2011 at 17:22 Comment(0)
T
3

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
Tragedienne answered 7/2, 2012 at 15:41 Comment(0)
M
1

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()
Merchant answered 17/5, 2011 at 19:9 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.