Reputation: 87
I'm trying to get WSH to run Python .pys scripts and I'm hitting a wall - I've tried this on two machines now, W7x64 and Server2012, same result both time, cscript always comes back with:
CScript Error: Can't find script engine "Python"
Procedure (all happening under local admin account):
'Registered: Python'
Try to run >cscript hello.pys get
CScript Error: Can't find script engine "Python"
Any clues? I don't really want to use ActivePython.
Upvotes: 4
Views: 2091
Reputation: 338
The original answer posted by @thecarpy has good information. There is one more thing to add. If you have multiple versions of Python installed, you need to make sure that the one which matches the version you have registered as the scripting engine is the first python.exe found in your search path. So putting it at the end of the path (as recommended in the previous answer) might not always work. I had a little more hair before I figured this out. 😅
Upvotes: 0
Reputation: 900
It appears that python on Windows is a PITA. So, I had your problem as well, I followed the following steps:
C:\Python27\
and C:\Python27\scripts
at the end of the Variable Value box (assuming you installed python in the location C:\Python27
).It still did not work for me, however, I was puzzled by <python_install>\scripts
and found pywin32_postinstall.py
in there, running that did the trick!
I kept getting the following trace:
Debugging extensions (axdebug) module does not exist - debugging is disabled..
I traced
it to Lib\site-packages\win32comext\axscript\client\framework.py
and commented out the trace
call that printed that message ... all good.
C:\Users\jdoe>type d:\python2vbs.wsf
<?XML Version="1.0" encoding="ISO-8859-1"?>
<?job error="true" debug="false"?>
<package>
<job>
<script language="VBScript">
<![CDATA[
public sub vbsOutput(strText)
wscript.echo strText & " (from vbsOutput)"
end sub
]]>
</script>
<script language="Python">
<![CDATA[
import sys
globals.vbsOutput('python testing')
]]>
</script>
</job>
</package>
C:\Users\jdoe>cscript d:\python2vbs.wsf
Microsoft (R) Windows Script Host Version 5.812
Copyright (C) Microsoft Corporation. All rights reserved.
python testing (from vbsOutput)
Upvotes: 1