This might be a weirdo mac problem, but recently p...
# general
This might be a weirdo mac problem, but recently pexs stopped working on my mac, saying no module named pkg_resources
Copy code
Lawrences-MacBook-Pro-2:aiq lawrencefinn$ python dist/app_admin_tool.pex 
Traceback (most recent call last):
  File "/Users/lawrencefinn/Documents/aiq/dist/app_admin_tool.pex/.bootstrap/pex/", line 394, in execute
  File "/Users/lawrencefinn/Documents/aiq/dist/app_admin_tool.pex/.bootstrap/pex/", line 92, in _activate
  File "/Users/lawrencefinn/Documents/aiq/dist/app_admin_tool.pex/.bootstrap/pex/", line 239, in activate
  File "/Users/lawrencefinn/Documents/aiq/dist/app_admin_tool.pex/.bootstrap/pex/", line 399, in _activate
  File "/Users/lawrencefinn/Documents/aiq/dist/app_admin_tool.pex/.bootstrap/pex/", line 143, in _update_module_paths
  File "/usr/local/Cellar/python@2/2.7.17/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/", line 37, in import_module
  File "/Users/lawrencefinn/.pex/code/7a8afd2b0ab97a76f9819ebfa3858979ce567b61/gen/", line 1, in <module>
ImportError: No module named pkg_resources
This used to work, and it works fine on non-mac machines (and maybe other laptops). Im on pants 1.27.0
Using pants run works fine, btw
I'm wondering if one of your deps does not properly declare a dependency on `pkg_resources`/setuptools - many assume that it is present in your environment, which could explain why it's working for Linux users if they have it but you don't on your mac I think a way to test this is to add
to requirements.txt, then add
to your
for the
target. If that works, we can figure out the best approach to address this
ill give it a whirl
i also have a weird feeling this is pyenv related
Still doesn’t work 😞
🤔 1
I'm shooting in the dark a bit, but my next thought would be to try to install
with the pip corresponding to
Also, could you try something like
python3 dist/app_admin_tool.pex
? given that it fails with
if i do
Copy code
python /Users/lawrencefinn/.pex/code/7a8afd2b0ab97a76f9819ebfa3858979ce567b61/gen/
that works fine
hmmm python3 has a whole different error
one that is actually in my code
👍 1
so python2 on my laptop is just a poop ?
💩 1
K, so that suggests that indeed this is something wrong with that
binary, e.g. if it's missing pkg_resources. That's consistent that things work on Linux but not Mac, as those are using different Python interpreters to run the PEX
a few years late is as good as every to upgrade python 😛
💯 1
On that note, see for how Pants v2 can help to pull off a migration! I first got involved with Pants working on Py3 migrations, so a topic near and dear to my heart
I think this should be ok, considering that this code is a bit segregated from other code…. ill give it a whirl!
❤️ 1
Useful data if you're willing to collect @polite-vase-75369 : 1. Grab a modern Pex PEX with tools:
curl -sSL <> > pex-2.1.39.pex
2. Use pex tools to extract some PEX-INFO metadata: python2.7 pex-2.1.39.pex your.pex info | jq '.distributions,.requirements'
3. And compare to python2.7 pex-2.1.39.pex your.pex repository info
is your pex and
is shorthand for the full path to the python2.7 discussed above.
ill give that a whirl
@enough-analyst-54434 what should i be comparing? see if some version is off?
uhhh so it randomly started working after a reboot. but i should upgrade to python3 anyway. thanks for the help!
If you could post or dm the output that would be easiest. Hopefully no names are sensitive.
well it started working, so i dunno if it is helpful anymore?
It's up to you, but its always helpful to root cause and hopefully find a way to prevent flaky from ever happening again.