Skip to main content
Question

Script not working in self-contained Python environment


ryonriley
Forum|alt.badge.img+6

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:

_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:

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

3 replies

Forum|alt.badge.img+31
  • Honored Contributor
  • 2721 replies
  • February 4, 2021

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
Forum|alt.badge.img+6
  • Author
  • New Contributor
  • 7 replies
  • February 4, 2021

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.


Forum|alt.badge.img+31
  • Honored Contributor
  • 2721 replies
  • February 4, 2021

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

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings