Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to run from binary #175

Closed
rodrigorianelly opened this issue Sep 30, 2022 · 2 comments
Closed

Not able to run from binary #175

rodrigorianelly opened this issue Sep 30, 2022 · 2 comments

Comments

@rodrigorianelly
Copy link

I'm trying to run this wrapper because I don't have access to AHK here in my work, but have access to python. I installed python package ahk 0.14.1 and ahk-binary 1.1.33.9 but my pip packages are installed for my user ("Defaulting to user installation because normal site-packages is not writeable"). I would like to know if this user installation have some influence in me not being able to run the script even having the binary installed or if I'm missing something...
My pip list

Package         Version
--------------- --------
ahk             0.14.1
ahk-binary      1.1.33.9
Jinja2          3.1.2
joblib          1.1.0
MarkupSafe      2.1.1
numpy           1.23.2
pandas          1.4.3
pip             22.2.2
plotly          5.10.0
python-dateutil 2.8.2
pytz            2022.2.1
scikit-learn    1.1.2
scipy           1.9.1
setuptools      63.2.0
six             1.16.0
tenacity        8.0.1
threadpoolctl   3.1.0
wheel           0.37.1

Here's the code

from ahk import AHK, Hotkey

ahk = AHK()

key_combo = 'a' # Define an AutoHotkey key combonation
script = 'send hi' # Define an ahk script
hotkey = Hotkey(ahk, key_combo, script) # Create Hotkey
hotkey.start()  #  Start listening for hotkey

Here's the output

PS Microsoft.PowerShell.Core\FileSystem::\\sdp-ntx-fs\dados$\rodrigorme\Desktop\ahk> py teste.py
Traceback (most recent call last):
  File "\\sdp-ntx-fs\dados$\rodrigorme\Desktop\ahk\teste.py", line 3, in <module>
    ahk = AHK()
  File "C:\Users\rodrigorme\AppData\Roaming\Python\Python310\site-packages\ahk\window.py", line 630, in __init__
    super().__init__(*args, **kwargs)
  File "C:\Users\rodrigorme\AppData\Roaming\Python\Python310\site-packages\ahk\mouse.py", line 61, in __init__
    super().__init__(**kwargs)
  File "C:\Users\rodrigorme\AppData\Roaming\Python\Python310\site-packages\ahk\gui.py", line 12, in __init__
    super().__init__(*args, **kwargs)
  File "C:\Users\rodrigorme\AppData\Roaming\Python\Python310\site-packages\ahk\script.py", line 89, in __init__
    self.executable_path = _resolve_executable_path(executable_path)
  File "C:\Users\rodrigorme\AppData\Roaming\Python\Python310\site-packages\ahk\script.py", line 49, in _resolve_executable_path
    raise ExecutableNotFoundError(
ahk.script.ExecutableNotFoundError: Could not find AutoHotkey.exe on PATH. Provide the absolute path with the `executable_path` keyword argument or in the AHK_PATH environment variable. You may be able to resolve this error by installing the binary extra: pip install "ahk[binary]"
@spyoungtech
Copy link
Owner

The AHK binary must be on PATH. In the case you've described, the location to which ahk-binary places the binary is not on PATH.

The best way to deal with this is to use a virtualenv.

python -m venv venv
venv\Scripts\activate
pip install ahk "ahk[binary]"
python script.py

Alternatively, fix your permissions and/or PATH issues.

@rodrigorianelly
Copy link
Author

Thank you for the feedback! It worked now!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants