Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tkinter - fails in a virtual env #56

Closed
vbabiy opened this issue Mar 14, 2011 · 12 comments
Closed

Tkinter - fails in a virtual env #56

vbabiy opened this issue Mar 14, 2011 · 12 comments
Labels

Comments

@vbabiy
Copy link

vbabiy commented Mar 14, 2011

When a virtualenv which shares the global environment site-packges is used for Tk based application using the global Tk.

Tkinter cannot initialise correctly in a virtualenv as it fails to correctly search for it's resources - which are still in the global python environment.

\Documents and Settings\Roger\Desktop\windows-install-bits>cd \venvtest

C:\venvtest>Scripts\activate.bat
(venvtest) C:\venvtest>python
Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter
>>> f= Tk()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'Tk' is not defined
>>> f= Tkinter.Tk()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "c:\Python26\Lib\lib-tk\Tkinter.py", line 1643, in __init__
    self.tk = _tkinter.create(screenName, baseName, className, interactive, want
objects, useTk, sync, use)
_tkinter.TclError: Can't find a usable init.tcl in the following directories:
    c:/Python26/lib/tcl8.5 c:/venvtest/lib/tcl8.5 c:/lib/tcl8.5 c:/venvtest/libr
ary c:/library c:/tcl8.5.2/library c:/tcl8.5.2/library



This probably means that Tcl wasn't installed properly.

>>> ^Z


(venvtest) C:\venvtest>deactivate

What I would expect is for a virtual env to work the same as the globale environment like so:--

C:\venvtest>c:\Python26\python.exe
Python 2.6.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import Tkinter
>>> f = Tkinter.Tk()
>>> ^Z


C:\venvtest>

After some experimentation I have found that copying c:\python26\tcl{tcl,tk}8.5 directories into the c:\venvtest\Libs solve the issues.


@vbabiy
Copy link
Author

vbabiy commented Mar 14, 2011

Actually a better way of fixing this would be to set the TCL_LIBRARY path in
activate.bat , or change FixTk.py to know about virtualenv's.


Original Comment By: Roger Gammans

@tinjaw
Copy link

tinjaw commented Apr 28, 2011

I too am just setting the environment variable TCL_LIBRARY path in activate.bat. So all virtualenv needs to do is add that line to activate.bat automagically.

@pumelo
Copy link

pumelo commented Jul 7, 2015

There is a thread on stackoverflow on this issue as well:
http://stackoverflow.com/questions/15884075/tkinter-in-a-virtualenv

I also just set the environment variable in activate.bat. However would be great if this would be done automatically.

@bobhy
Copy link

bobhy commented May 22, 2016

Still a problem in virtualenv 15.0.1.
... just sayin'

@stale
Copy link

stale bot commented Jan 14, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Just add a comment if you want to keep it open. Thank you for your contributions.

@stale stale bot added the wontfix label Jan 14, 2019
@CharlesB2
Copy link

Looks like it's still a problem

@stale stale bot removed the wontfix label Jan 15, 2019
@stale
Copy link

stale bot commented Apr 15, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Just add a comment if you want to keep it open. Thank you for your contributions.

@stale stale bot added the wontfix label Apr 15, 2019
@stale stale bot closed this as completed Apr 22, 2019
@c0d3h4x0r
Copy link

This is still a problem. I hit it most recently on Mac -- the fix for #93 did not resolve the issue on Mac.

@c0d3h4x0r
Copy link

Someone need to reactivate this issue. Just because it has sat around without getting any traction, that doesn't mean it's no longer an issue. It just means the project maintainers have not prioritized it like they should.

@fxthomas
Copy link

fxthomas commented Dec 2, 2020

On Windows, still an issue with Python 2.7 but seems solved in Python 3.8 with the venv module.

@pradyunsg
Copy link
Member

Please feel free to file a new issue, with the error message, reproduction instructions and information on how you installed Python.

@gaborbernat
Copy link
Contributor

It just means the project maintainers have not prioritized it like they should.

Considering project maintainers are not paid, and do it for free in their personal time I don't believe you can talk about they should. If this issue is a problem for you, please consider filling in a PR with a fix. All the code is open-source and freely available to you.

@pypa pypa locked and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

9 participants