Keyboard Maestro has problem importing python scripts - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Keyboard Maestro has problem importing python scripts (/thread-12535.html) |
Keyboard Maestro has problem importing python scripts - bobsmith76 - Aug-29-2018 I'm trying to run my python scripts with the click of one button. i'm tired of hunting for my terminal, activating it, then inputting an alias. so i've looked around for some things then can run python scripts on a mac with the click of one button. i've decided to go with keyboard maestro since i've had some very moderate success with it. in any case, when it runs my scripts it has trouble importing all of my modules. I can run simple python scripts with KM (keyboard maestro) but when I try to run something quite complex it breaks down. KM cannot import certain modules. So I call one module which uses xlwings. When KM tries to import xlwings it has trouble importing the modules that xlwings imports. Look at this from main import * File "/Users/kylefoley/PycharmProjects/inference_engine2/inference2/proofs/other/activities/main.py", line 6, in import xlwings File "/library/frameworks/python.framework/versions/3.6/lib/python3.6/site-packages/xlwings/init.py", line 25, in from . import _xlmac as xlplatform File "/library/frameworks/python.framework/versions/3.6/lib/python3.6/site-packages/xlwings/_xlmac.py", line 10, in import aem ModuleNotFoundError: No module named 'aem'So you can see that it successfully executes from main import *which is my code. Then it imports xlwings. After that it goes into another module which is not my code. This is where things start to go wrong. It executes line 25 of in the xlwings module but then it cannot execute line 10 of the xlmac.py module. Really at a loss here. RE: Keyboard Maestro has problem importing python scripts - Larz60+ - Aug-29-2018 please always post errors (entire thing, without modification) it will usually immediately point to the error. For any modules that are missing, from command line, run: # To make sure it's the right pip: [python]pip -V# if not, try: pip3 -V#whichever one is associated with the right version of python is the one to use, then: pip install package name[/python] RE: Keyboard Maestro has problem importing python scripts - bobsmith76 - Aug-29-2018 The program runs from command line but not from keyboard maestro. I have the module it's just that KM is not finding it. Let me post the entire error message 2018-08-29 11:51:06 Traceback (most recent call last): File "/Users/kylefoley/PycharmProjects/inference_engine2/inference2/Proofs/other/activities/bd.py", line 3, in <module> from main import * File "/Users/kylefoley/PycharmProjects/inference_engine2/inference2/proofs/other/activities/main.py", line 6, in <module> import xlwings File "/library/frameworks/python.framework/versions/3.6/lib/python3.6/site-packages/xlwings/__init__.py", line 25, in <module> from . import _xlmac as xlplatform File "/library/frameworks/python.framework/versions/3.6/lib/python3.6/site-packages/xlwings/_xlmac.py", line 10, in <module> import aem ModuleNotFoundError: No module named 'aem' Macro “Execute a Shell Script” cancelled (while executing Execute Shell Script).Once again, the line import aemWorks perfectly fine when using command line or PyCharm but not when the program is run from Keyboard Maestro. RE: Keyboard Maestro has problem importing python scripts - bobsmith76 - Aug-29-2018 Ok, I've made a little bit of progress. I encounter versions of this error when I use terminal and I solve it by doing this: import sys str1 = "/library/frameworks/python.framework/versions/3.6/lib/python3.6/site-packages/" sys.path.append(str1)When I remove that code I get the following error: Traceback (most recent call last): File "/Users/kylefoley/PycharmProjects/inference_engine2/inference2/Proofs/other/activities/main.py", line 6, in <module> import xlwings ModuleNotFoundError: No module named 'xlwings'So I'm on the right track. I just need to find out what path to append to sys so that I do not get this error: Traceback (most recent call last): File "/Users/kylefoley/PycharmProjects/inference_engine2/inference2/Proofs/other/activities/main.py", line 6, in <module> import xlwings File "/library/frameworks/python.framework/versions/3.6/lib/python3.6/site-packages/xlwings/__init__.py", line 25, in <module> from . import _xlmac as xlplatform File "/library/frameworks/python.framework/versions/3.6/lib/python3.6/site-packages/xlwings/_xlmac.py", line 10, in <module> import aem ModuleNotFoundError: No module named 'aem'So after I found the module 'aem' I put in the following code: str1 = "/library/frameworks/python.framework/versions/3.6/lib/python3.6/site-packages/aeosa/aem/" sys.path.append(str1)That didn't work however. I'm getting the same error message. |