简体   繁体   English

用Python脚本导入Winreg

[英]Import Winreg in a Python Script

I am currently working on a Jenkins freestyle job and one of the build steps is to run a Python script. 我目前正在从事Jenkins自由式工作,构建步骤之一是运行Python脚本。 I have been working on this job for a couple of days now and this is one of the last build steps needed to finish it off. 我已经从事这项工作了几天,这是完成它所需要的最后一个构建步骤之一。 I have reached a point where I get an error letting me know that the import winreg module does not exist. 我到了一个错误,告诉我导入winreg模块不存在。

I have installed Jenkins on CentOS and have read some documentation stating that I am unable to import this module on this distribution. 我已经在CentOS上安装了Jenkins,并阅读了一些文档,说明我无法在此发行版上导入此模块。

Is there no other way to solve this than to switch over to a Windows machine? 除了切换到Windows机器,没有其他解决方法吗?

Thanks 谢谢

It makes sense, the _winreg docs says: _winreg文档得很对:

These functions expose the Windows registry API to Python. 这些函数将Windows注册表API公开给Python。

You could try to make it run on a windows virtual machine in your centos host or just following the official Installing+Jenkins+on+Red+Hat+distributions guide 您可以尝试使其在centos主机中的Windows虚拟机上运行,​​或者仅遵循官方的Installation + Jenkins + on + Red + Hat + distributions指南

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

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