Python can't find file

I created my Python per the blog, created a Script and assigned it to the environment but not matter what script we try and run we get this error

We are on version 4.2.11

[INFO]C:\REC\Python311\python.exe: can't open file 'C:\\ProgramData\\UniversalAutomation\\Repository\\{scriptPath}': [Errno 2] No such file or directory

Does the Python script you’re trying to call from the repository actually exist?

If you examine the variable scriptPath is it correct when appended to C:\\ProgramData\\UniversalAutomation\\Repository\\

Yes they do.

Great. What about the other question I asked? You’re trying to call C:\\ProgramData\\UniversalAutomation\\Repository\\{scriptPath}, so what is scriptPath being filled with? If it’s not just the filename or a subfolder\filename, and it’s appending the FULL path (i.e. C:\\ProgramData\\UniversalAutomation\\Repository\\C:\\ProgramData\\UniversalAutomation\\Repository\\Python\ Scripts\\script-to-run.py then that would be why it’s not working, because it should only be C:\\ProgramData\\UniversalAutomation\\Repository\\Python\ Scripts\\script-to-run.py.

I might have misunderstood the blog post on setting up the environment that.
I assumed by placing {scriptPath} in the environment that PSU would automatically insert the script.

If I put the script path in the environment would I need a dedicated python environment for every python script?

I see. No, you created it correctly, and no you don’t need a dedicated environment for every script.

To use the environment, are you referencing it in a scheduled job, an API (“Endpoint”), etc.?

All I did was install Python on the PSU server, setup the environment, create a new Script with my python code in it, and then try to Run. Thats when it fails.

I get that, but HOW are you running it? From inside of an Endpoint? A scheduled job?

Right on the main PSU web page. Pressing Run button after editing my script. Am I understanding your question correctly?

I just created a Python environment on my PSU instance, and I can get the same error you’re seeing. It appears to be an issue with the path in the environment not expecting a full path. It looks like it needs to just be “python” or “python.exe”. Doing that, though, I then get a different error: An error occurred trying to start process 'python' with working directory C:\ProgramData\UniversalAutomation\Repository'. The system cannot find the file specified. even though I can start Python with just “python” or “python.exe” directly from the PSU server without any problem. It may be better to just launch the Python script from inside of a PowerShell script and avoid this issue altogether.

By any chance did you add python to your environment variables and test?

That was all done (and verified) during the Python installation process.

Call Python from within Powershell seems to defeat the purpose of creating a Python environment.

I agree but, between having something or having nothing, which would you prefer?