-
Notifications
You must be signed in to change notification settings - Fork 229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"failed to parse CPython sys.version..." error when running under .Net 6 #820
Comments
I've found one solution, which is to execute the following script right after creating the ScriptEngine object:
It fixes the issue (I'll refine it to insert the correct version no.s rather than hardcode) but is there a better approach? |
@andyste1 Sorry for the late reply. I guess you're not using the IronPython version of the standard library? I think you can override the version string via |
@slozier, no problem. When you say "standard library", I assume you mean the C:\Python27\ folder that was installed by Python. |
Yes and no. I am referring to
Yes, that's the method. The arguments will map to |
We have a large .Net 4.x WPF desktop application that is in the process of being migrated to .Net 6. The app calls numerous py modules, one of which contains the following line of code:
import platform
...
print 'Using Python {0}'.format(platform.python_version())
This works fine with the .Net 4.x app, but the .Net 6 app fails with a ValueErrorException:
failed to parse CPython sys.version: '2.7.12 (2.7.12.1000)\n[.NETCoreApp,Version=v3.1 on .NET 6.0.6 (64-bit)]
The above line of code is really only there for informational purposes, and in theory could be removed. However we have a large customer base, and it's possible that this particular py module might contain customer-specific code, so I can't go replacing this module as part of our installation process.
I have found that I can hack the Python 2.7 \Lib\platform.py file, changing the _sys_version() function to return some hardcoded version values. If all else fails then I could deploy this modded file as part of the .Net 6 app installer.
However I was just wondering if there might be a way to fix this from the .Net side? Clutching at straws, but perhaps being able to modify that offending version information via one of the IronPython classes?
The text was updated successfully, but these errors were encountered: