我最近开始使用Python,并在以管理员身份运行的Windows 10计算机上安装了3.7.3版本。然后,我在命令提示符中运行以下命令以安装xmpppy软件包
python -m pip install xmpppy
接下来,我创建了以下使用上述xmpppy软件包的base.py文件
#!/usr/bin/env python
import xmpp
user="user"
password="pword"
server="server"
jid = xmpp.JID(user)
connection = xmpp.Client(server,debug=[])
connection.connect()
result = connection.auth(jid.getNode(), password,"LFY-client")
connection.sendInitPresence()
while connection.Process(1):
pass
现在我运行命令
python base.py
在存在base.py文件的文件夹中,我收到以下错误消息:
Traceback (most recent call last):
File "base.py", line 3, in <module>
import xmpp
File "C:\Users\AGO109\AppData\Local\Programs\Python\Python37\lib\site-packages\xmpp\__init__.py", line 29, in <module>
import simplexml,protocol,debug,auth,transports,roster,dispatcher,features,browser,filetransfer,commands
ModuleNotFoundError: No module named 'simplexml'
在文件夹C:\ Users \ AGO109 \ AppData \ Local \ Programs \ Python \ Python37 \ lib \ site-packages \ xmpp simplexml.py,protocol.py等中,所有这些都存在,并且Windows系统变量包含以下路径: python和软件包,这是什么问题?
答案 0 :(得分:0)
我正面临着同样的问题。
尝试使用class Node
{
int value;
Node left, right;
public Node(int item)
{
value = item;
left = right = null;
}
}
public class BinaryTree {
Node root;
public Node findNode(int value) {
Node focusNode = root;
if (focusNode == null){
return null;
}
while (focusNode.value!= value) {
// If we should search to the left
if (value< focusNode.value) {
// Shift the focus Node to the left child
focusNode = focusNode.left;
} else {
// Shift the focus Node to the right child
focusNode = focusNode.right;
}
}
return focusNode;
}
之类的命令安装每个软件包,然后运行代码。我被困在安装pip install simplexml
上。
或者,您可以尝试使用python安装随附的transports
进行切换。由于sleekxmpp
的最新版本与sleekxmpp
的2006年相比于2017年发布,因此我计划继续使用xmpppy
库。如果您按照https://pypi.org/project/sleekxmpp/上的样板代码更新代码以使用sleekxmpp
,则XMPP连接有效。