python调用centos防火墙_centos 7查看防火墙报错(已解决,之前安装过python3)

在尝试重启CentOS 7的firewalld服务时遇到了错误,'firewalld.service'的控制进程以错误状态退出。通过'journalctl -xe'查看详细信息发现'firewalld'未知操作。进一步检查发现'firewall-cmd'命令引用了缺失的'gi.repository.GObject'模块。解决方法是在'/usr/bin/firewall-cmd'文件的第一行添加'python2.7',然后保存退出,成功启动firewalld服务。
摘要由CSDN通过智能技术生成

[root@localhost ~]# service firewalld restart

Redirecting to /bin/systemctl restart firewalld.service

Job for firewalld.service failed because the control process exited with error code. See "systemctl status firewalld.service" and "journalctl -xe" for details.

[root@localhost ~]# systemctl firewalld restart

Unknown operation 'firewalld'.

[root@localhost ~]# service firewalld stop

Redirecting to /bin/systemctl stop firewalld.service

[root@localhost ~]# service firewalld start

Redirecting to /bin/systemctl start firewalld.service

Job for firewalld.service failed because the control process exited with error code. See "systemctl status firewalld.service" and "journalctl -xe" for details.

[root@localhost ~]# systemctl status firewall

Unit firewall.service could not be found.

[root@localhost ~]# firewall-cmd --state

Traceback (most recent call last):

File "/usr/bin/firewall-cmd", line 24, in

from gi.repository import GObject

ModuleNotFoundError: No module named 'gi'

以上提示中提到了“/usr/bin/firewall-cmd”,我们输入以下命令:

vim /usr/bin/firewall-cmd

修改第一行,在python后面添加数字2.7:

保存退出即可

### 欢迎关注微信公众号“ **IT客**“ ,投稿邮箱 itkeyy@163.com

![](http://ww1.sinaimg.cn/large/006M5LK3ly1g5r7cupix3j30go0gon1i.jpg)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值