Script not working in self-contained Python environment

ryonriley
New Contributor II

After figuring out the error in my other Python thread, I'm now running into a different problem.

I used the relocatable python tool after following @tlarkin's clear instructions (thank you again!) to create a self-contained Python3 environment that can be shipped out to client machines. I then changed the environment on the script itself to reflect the location of the self-contained py3 environment (specifically, the symlink): /opt/advisory/bin/python3

The script works when invoked from Self Service on both my own machine and a VM, but does not work on any of my colleagues machines. The error they're receiving is:

2296d2103b3e4f3ca08b36eb8f68a706

_tkinter.TclError: Can't find a usable init.tcl in the following directories:

I'm not sure how to resolve since I can confirm the tkinter module is installed correctly and works in the self-contained environment. To test, I invoked it from the path /opt/advisory/py3/Python.framework/Versions/3.9/bin/python3:
885c9285e8ff41e784a6ae1519162fbb

I assume this is because of a Python path issue, but I'm not entirely sure. Any help would be greatly appreciated!

3 REPLIES 3

tlarkin
Honored Contributor

What does pip list for your python packages?

/opt/advisory/Python.framework/Versions/3.8/bin/pip3 list

Does it list the proper packages and versions? Did you install your Python into /Library?

ryonriley
New Contributor II

What does pip list for your python packages?

  • It's a lot to show in a screenshot, but certifi, chardet, idna, pip, pyobjc (and frameworks), requests, setuptools, and urllib3.

Does it list the proper packages and versions? Did you install your Python into /Library?

  • It lists everything besides tkinter, but I can see the module under /opt/advisory/py3/Python.framework/Versions/3.9/lib/python3.9. However, I don't see it under the /opt/advisory/py3/Python.framework/Versions/3.9/lib/python3.9/site-packages folder.

RE; installing Python to /Library - I think so. I originally installed the Python.org 3.9.1 version to the default location.

tlarkin
Honored Contributor

So, when I build my py3 env I used a requirements.txt file and I use that feature in relo python to do so. Which is just this, I don't ship a lot of extra modules yet.

requests
xattr
pyobjc
requests-oauthlib

so then when I package up my Framework folder those are in the site packages already. If pip doesn't list it for your env perhaps it is not installed or the wrong versions? Is tkinter a standard package? I haven't touched that module in a few years so I do not remember.

Looks like it is not included

pip3 list | grep -i "tk"
pyobjc-framework-AppleScriptKit                   6.2.2
pyobjc-framework-EventKit                         6.2.2