Hello,
I'm using a python script in a EasyMorph Desktop project.
To be able to use it with my personal computer and with our server, I've created a venv where I installed python.
The venv is located inside the easymorph space, because we would like to tell this venv is for this specific project.
It works well with my computer, but when I try on the server it seems to try to use the python from the user files, and not the one in the venv.
This is my project environment.
It's located on our Server with EasyMorph Server, in our default space.
It's inside a shared folder, so we can use the path with the server and with our computers.
Inside the folder you can see a venv with the python installation.
In the EasyMorph project, this is how I use my python script :
In the "Application" section, I put the python.exe located in the venv folder.
So it should use this python version to run the script.
I wrote all the different errors in a log file, to see what happens in case of error.
With my personal computer all is working.
But if I execute the project on the server, I have this error :
No Python at '"C:\Users\MyUser\AppData\Local\Programs\Python\Python312\python.exe'
What I understand here : the "Run program" action is not using the python located in the venv.
I've opened the .morph with a text editor to see if I can see somewhere a line with my user.
I found nothing.
I also tried to use the "Working directory" inside the "Run program" action, but it's the same result.
Can you help me ?
Thank you
Hi @WindBlast,
RunProgram executes whatever executable path you pass in; it knows nothing about Python/PYTHONHOME specifically. Could it be that the script itself invokes subprocess.run(["python", ...])
or os.system("python ...")
or something similar?
To isolate the issue, easiest is to create a minimal test script that just prints Hello, world!
(no imports) and see whether that runs.
Also, please double-check the venv's pyvenv.cfg file. If you created venv locally and then copied it (even if created with --copies), it's not guaranteed to work on another machine (from docs):
A virtual environment is (amongst other things): ...
Not considered as movable or copyable – you just recreate the same environment in the target location.
(...) environments are inherently non-portable, in the general case.
1 Like
Hello,
Thank's for your reply.
In fact when using any script, when using the python in the venv, it tries to use everytimes the python defined in the pyvenv.cfg file.
This definition is using the python located inside my computer, not the server.
When replacing it by the python located in the venv, it just start a python process again and again.
I think the venv is not what I need.
After trying a lot of things with the venv, I looked for an other way.
I'm not using a lot of python scripts or python deployment on servers.
I find something working really good : pyinstaller.
It compile the python, modules and dependencies inside a .exe file.
I take this file, put it on the server and then run it in EasyMorph with "Run program", and it works like a charm.