Hello,
we are experiencing issues when trying to run a Python script through the new module CALL PYTHON on EasyMorph Server. I've read other articles but can't find a solution.
- Python is installed on the server under C:\Program Files.
- The environment variable is set correctly and includes the Python path.
- Running the script from command prompt on the server works without any problem.
-Running the script locally through EasyMorph Desktop also works fine.
The issue only occurs when executing the task via EasyMorph Server.
Could you please advise if there are additional configurations required on the server, or how we can resolve this issue?
Thanks.
Riccardo
Hi @Riccardo_Migliori ,
Thank you for reporting this issue. We would need additional details to understand the problem.
Could you please specify how the issue is observed?
Does the action fail, or does it work but produce an unexpected result?
If there is an error, please provide the text of it.
Is the default server worker being used?
Which Python version is being used?
Running the script from command prompt on the server works without any problem
To clarify, do you mean using the PowerShell action or the Run Program action? If possible, please specify the exact command being used.
Also, please provide a screenshot of the action properties (both tabs). I am assuming you are trying to run in 'Default' mode, is that correct?
Thanks
Hello Vlad, thanks for reaching out.
I'm using the Call Python new action:
What is been logged on our server is the message:
These are the env. variables on the servers:
The Easymorph Server service is run by Administrator user which has fully access to the server.
When I say "Running the script from command prompt on the server works without any problem" I mean like this:
What you are referring to is what we did when we had a similar issue a while ago, and the workaround was using the action "run program" to start a powershell task that would run a python script. This was the workaroud but I would prefer to solve the issue once and for all:
If you need other details let me know, thanks again for the help.
Riccardo
Hi @Riccardo_Migliori ,
Thank you for the additional information.
A 'Could not start python' type error is emitted when 'python.exe' is not found in PATH or the current user has no access to it. The action works the same way on Desktop and Server, so it is surprising that it fails on the server specifically. The application essentially invokes 'python {script} args'.
To help us further diagnose the issue, could you add a PowerShell action with the following content, run it on the server in 'Capture output' mode, and save its output to a file:
python --version
python -c "import sys; print(sys.executable)"
whoami
$env:Path -split ';'
Then please share the result file.
Also, could you share how 'parser.ps1' calls python?
Additionally, as a workaround, you could try using the venv
option. First, create a venv
via
& "C:\Program Files\Python313\python.exe" -m venv test_venv
in an accessible location (using an absolute path to ensure the correct Python installation is picked). Then configure the CallPython action to point to the root of that venv (e.g. C:\test_venv
) and run the script.
Thanks
Hi Vlad, thanks for your time.
Here's the output file:
ps_output.txt (530 Bytes)
parser.ps1 is like this:
$pythonProgramPath = "C:\Users\Administrator\AppData\Local\Programs\Python\Python313\python.exe"
$pythonScriptPath = "X:\EasyMorphServer_Data\....\PyFiles\parser.py"
$file = "C:\Users\Administrator\Desktop\hot.dat"
$pythonOutput = & $pythonProgramPath $pythonScriptPath $file
$pythonOutput
Now I've installed Python on C:\Program Files\Python313 so I'll have to update this, but it'll work the same way.
I'll try to install a venv for python tomorrow but for various reasons I'd prefer it working through the Default option.
Riccardo
Thank you for providing additional information.
I see that in the output file there is no Python version printed, and PATH is different from what was shown in the earlier screenshot.
The saved PowerShell output shows only whoami
and PATH lines; there is no output from python --version
or python -c ...
, which is consistent with Python not being invokable in the effective context. Also note that C:\Program Files\Python313
is missing from the printed PATH.
It is possible that PATH was inherited before Python was installed and that the service needs a restart to recognize it. Since it looks like you installed Python to Program Files recently, this could be the cause. Could you try restarting the server?
Separate question: would you prefer having an option to specify the full filesystem path to a specific python.exe
in the settings, rather than relying on PATH with the Default option?
Hi Vlad.
I noticed that Python in C:/Program Files/Python
doesn’t appear in PATH, even though it’s listed in the environment variables, like this:
I’ll try restarting the server as soon as possible and will update you on the outcome.
Regarding your question: I’d love to have an option in the settings to specify the full filesystem path to a specific python.exe
. This would make it easier to use and help with diagnosing potential errors.
Riccardo