python3结构导入错误:无法导入连接


import os
import string
from fabric import Connection
import configparser
import socket

config = configparser.RawConfigParser(allow_no_value=True)
configFilePath = r'/root/config.ini'
config.read(configFilePath)
puser = config.get('Server', 'user')
#print (puser)
db_server = list(config.items('Database'))
#print (db_server)

def host_connect():
for key in db_server:
print (key[0])
conn = Connection(host="puser@{0}".format(key[0]))
conn.run('ps -ef | grep postgres')

我正在尝试运行此代码,但由于追踪(最近一次通话(:文件"psql_cleanlogs.py",第6行,位于从结构导入连接ImportError:无法导入名称"Connection">

我在不同的代码中做过同样的过程,运行得很好,但现在它正在制造麻烦。我正在使用python3虚拟环境

我遇到了类似的问题,我检查了下载的fabric包的内容,它没有Connection.py(可能是我下载包的错误repo(。我从正确的存储库(https://pypi.python.org/simple(中安装了fabric2,它工作正常。

from fabric2 import Connection

最新更新