Opened 4 years ago

Closed 18 months ago

#59147 closed defect (fixed)

py*-tkinter 3.6.9 is not compatible with virtualenvs

Reported by: paulray (Paul Ray) Owned by: jmroot (Joshua Root)
Priority: Normal Milestone:
Component: ports Version: 2.6.0
Keywords: Cc: rieder (Steven Rieder)
Port: python27 python35 python36 python37 py-tkinter

Description

The preferred way to use virtualenvs is without the --system-site-packages so that the virtualenv is encapsulated and installs its own stuff. However, if your python code uses tkinter there is a problem. The base ports pythonXX do not install tkinter, it is installed by pyXX-tkinter. Unfortunately, this puts _tkinter*.so into the site-packages directory, instead of in the main python library directory. Most python installs include tkinter natively and do not require site-packages to see it, so this means you can't use tkinter without having site-packags in your path (e.g. in a virtualenv). This would not really be a problem if tkinter were installable by pip, since it could just be installed in the virtualenv. So, I'd like to see one of two solutions implemented:

  • Make pythonXX port install tkinter as part of the base python
  • Or, make pyXX-tkinter create the _tkinter*.so (or a soft link to it) in the normal python directory, so that site-packages is not required for tkinter to work.

I'm guessing that the reason that tkinter is a separate port from python itself is related to the possible variants for tk (x11, quartz) and/or so that python itself does not have a direct tk dependency.

(Note that I hacked a solution to this problem on my system using this command: % sudo ln -s /opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/_tkinter.cpython-36m-darwin.so /opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/_tkinter.cpython-36m-darwin.so Obviously this is not an optimal solution! But if this were done by port install py36-tkinter all would be good.)

Change History (7)

comment:1 Changed 4 years ago by mf2k (Frank Schima)

In the future, please add the port maintainer(s) to Cc (port info --maintainers python36 py36-tkinter), if any.

comment:2 Changed 4 years ago by mf2k (Frank Schima)

Owner: set to jmroot
Port: python27 python35 python37 py-tkinter added; py36-tkinter removed
Status: newassigned

comment:3 in reply to:  1 Changed 4 years ago by paulray (Paul Ray)

Replying to mf2k:

In the future, please add the port maintainer(s) to Cc (port info --maintainers python36 py36-tkinter), if any.

Oops, sorry. Thanks for fixing that!

comment:4 Changed 4 years ago by paulray (Paul Ray)

Is anyone considering fixing this? I keep running into this issue.

comment:5 Changed 2 years ago by rieder (Steven Rieder)

This is still an issue as of today. (edit: and with more recent python ports, including py310-tkinter)

Last edited 2 years ago by rieder (Steven Rieder) (previous) (diff)

comment:6 Changed 2 years ago by rieder (Steven Rieder)

Cc: rieder added

comment:7 Changed 18 months ago by jmroot (Joshua Root)

Resolution: fixed
Status: assignedclosed

In 03fd9ff75107ebb4d664b0d51fbb40d00a5c8be5/macports-ports (master):

python310: update to 3.10.8

Build gdbm and tkinter extensions with PEP517, and install them to
lib-dynload.

Fixes: #59147

Note: See TracTickets for help on using tickets.