从 UWP 运行 python 脚本 [英] Run python script from UWP

查看:31
本文介绍了从 UWP 运行 python 脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读并研究了整个网络,包括这里:Windows 通用应用程序:从 C# 调用 python 方法[关闭]

I've already read and researched all over the net including here: Windows Universal Apps: Call python method from C# [closed]

而且我了解UWP是沙盒,不能打开其他进程.尽管如此,我别无选择,只能在 UWP 应用程序中使用 python API.上面链接中的答案对我来说还不够清楚,我希望得到任何解决方案,即使它不是直接的.

And I understand that UWP is a sandbox and can't open other processes. Nonetheless, I got no other choice but to use python API inside UWP app. The answer in the link above is not clear enough for me and I hope to get any solution, even if it's not a direct one.

当然,我试过 IronPython,但它不起作用.以及引发拒绝访问"的 Process/ProcessInfo.Azure 也不是一种选择.

Of course I tried IronPython which is not working. And Process/ProcessInfo which brigs-up "access denied". Azure is also not an option.

谢谢.

推荐答案

如果您的应用程序旨在仅在 PC(而不是手机、HoloLens、xbox 等)上运行 Python 脚本,那么您可以使用 API来自 UWP 桌面扩展 SDK:

If your app is intended to run on the Python script only on PC (and not on phones, HoloLens, xbox, etc.) then you can use an API from the UWP desktop extension SDK:

FullTrustProcessLauncher

此 API 允许您从 UWP 启动包含在应用程序包中的常规完全信任 EXE.然后,这些 EXE 将在 appcontainer 沙箱之外运行,您可以执行诸如 Python 脚本(以及更多场景)之类的内容.使用此 API 时,您的应用可以继续在 HoloLens 等设备上运行,但无法在这些平台上启动那些完全信任的流程.

This API allows you to launch regular full trust EXEs that are included in your app package from your UWP. Those EXEs will then run outside of the appcontainer sandbox and you can execute things like Python scripts (and many more scenarios). When using this API your app can continue to be run on HoloLens etc., but it won't be able to launch those full trust processes on those platforms.

我的博客上有关于此主题的教程:https://stefanwick.com/2018/04/06/uwp-with-desktop-extension-part-1/

I have a tutorial on this topic on my blog: https://stefanwick.com/2018/04/06/uwp-with-desktop-extension-part-1/

这篇关于从 UWP 运行 python 脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆