简体   繁体   English

Python跨平台

[英]Python cross platform

If I create a gui for windows using python 2.6 and Qt, and then want to running in solaris or linux world. 如果我使用python 2.6和Qt为Windows创建GUI,然后希望在solaris或linux world中运行。

What do I need on both systems, I'm guessing 2.6 and Qt for both platforms. 我在两个系统上都需要什么,我猜这两个平台都需要2.6和Qt。 Is this correct or would there be a better solution. 这是正确的还是会有更好的解决方案?

If wxpython, the same right? 如果是wxpython,同样正确吗?

To run a Python application, one obviously need to have the Python interpreter installed, usually at least the same version used for developement (but sometimes you didn't use features new to that version, so the code is backwards-compatible). 要运行Python应用程序,显然需要安装Python解释器,通常至少与用于开发的版本相同(但有时您不使用该版本的新功能,因此代码向后兼容)。 A newer version should work, too - only Python 3 isn't backwards compatible to 2.x versions. 较新的版本也应该起作用-仅Python 3不向后兼容2.x版本。

Also, all third party libraries need to be installed, of course. 另外,当然需要安装所有第三方库。 So if your GUI uses PyQt, users need PyQt installed. 因此,如果您的GUI使用PyQt,则用户需要安装PyQt。 If you use wxPython, users need wxPython installed. 如果使用wxPython,则用户需要安装wxPython。

Apart from that, it is possible, although much harder than with certain other languages, to break compability with other platforms, especially when dealing with files and paths manually (eg joining an absolute with a relative path with "\\\\" instead of using the cross-platform os.path.join ). 除此之外,尽管比某些其他语言要难得多,但可能破坏与其他平台的兼容性,尤其是在手动处理文件和路径时(例如,使用"\\\\"将绝对路径与相对路径连接起来,而不是使用跨平台os.path.join )。

It is possible (and especially for applications aimed at casual users, especially on Windows) to "freeze" a Python program and libraries it uses into an executable file (ideally without dependencies, I don't know if that's always the case in practice). 可以(尤其是针对针对临时用户的应用程序,尤其是在Windows上)将其使用的Python程序和库“冻结”到可执行文件中(理想情况下没有依赖关系,我不知道实践中是否总是这样) 。 There are a few tools that work for one platform, and the supposedly cross-platform cx_Freeze . 有一些工具可以在一个平台上运行,而所谓的跨平台cx_Freeze也可以 Although I don't know if one can produce a Linux executable on a windows machine... 虽然我不知道是否可以在Windows机器上生成Linux可执行文件...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM