tebelorg/RPA-Python

Chance of possible python command issue with newer Macs [fixed]

kensoh opened this issue · 13 comments

kensoh commented

Newer macOS does not come with Python installed. Even if users install manually, there could be a possibility of missing python command, at least for some reports from users of TagUI RPA engine here - aisingapore/TagUI#792 (comment)

Raising a pre-emptive issue here, so that rpa package users can both try the workaround in the link above and also please share here if you are running into this problem, so that I can confirm if this is also a problem for rpa package users and make a permanent solution.

there is no python, only python3 by default
solution in the link helped.
in files

  • /Users/user/.tagui/src/casperjs/bin/casperjs
  • /Users/user/.tagui/src/casperjs/tests/clitests/runtests.py
  • /Users/user/.tagui/src/slimerjs/slimerjs.py

change first line from #!/usr/bin/env python to #!/usr/bin/env python3

pip3 install rpa
install homebrew
brew install php
open finder then go to path /Users/<YOUR_USER>/.tagui/src/
edit files casperjs runtests.py slimerjs.py as per previous comment above
python3 sample.py

kensoh commented

Thanks @antmanin and @marcelocecin! Have you or could you kindly try if using symlink work? I can't really test this because my Mac is old and has both python 2 and python 3 now to accurately assess if below works.

If you don't have python command on Mac, could you run below to symlink python command to python 3? Folks who has similar issue without python command can try and share your feedback here too so I can update readme on best solution.

sudo ln -sf /usr/bin/python3 /usr/bin/python

Hi Ken, unfortunately it doesn't work

kensoh commented

Thanks @marcelocecin! Let me think over it. I think to ask users to hack those 3 files is an unacceptable solution. That should happen automatically behind the scenes. I'll have to chew over this because the execution pathways for Mac and Linux are similar so I have to be careful not to break Linux users scripts for the convenience of Mac newer version users.

kensoh commented

Writing the logic in _patch_macos_pjs() it seems to be doable and not fall into rabbit hole.

kensoh commented

Hi @marcelocecin and @antmanin could you kindly help me run the following on your Mac?

I want to confirm the condition to check to autohack the 3 files automatically. Below should show False then True.

import os
print(os.system('python --version > /dev/null 2>&1') == 0)
print(os.system('python3 --version > /dev/null 2>&1') == 0)

For mine I already have Python 2 so can't be tested. But when I test with python4 it returns False as expected.

Hi Ken, I'm traveling without my laptop. When I have access to it I will reply.

kensoh commented

Sure @marcelocecin no hurry! This execution pathway affects all Mac users.
So I would wait for at least 1 PC with the target setup that works before rolling it out via PyPI.
In the meantime, folks can follow above workaround and change manually.

@kensoh that works for me
image

kensoh commented

Thanks @antmanin! Hi @antmanin and @marcelocecin I've published v1.50. If you could, can you revert the local changes you made to the 3 files and see if this updated version automatically fixes the problem? It should be fine.

It will detect if user macOS has no python but has python3 and do the changes itself on first run.

kensoh commented

Above change will fix this round of issue when newer macOS has no python command.

Hopefully no more headaches from macOS.. The OS increasingly makes it hard for developers.

kensoh commented

Closing issue because new users will already be using the latest package version that has this fix. Old users shouldn't have a use case where it is working and suddenly broken.