[英]Python 3 Windows install giving package error ModuleNotFoundError
I have recently started using Python and have installed version 3.7.3 on my Windows 10 machine running as administrator.我最近开始使用 Python 并在以管理员身份运行的 Windows 10 机器上安装了 3.7.3 版。 I then ran the following command in a command prompt to install the xmpppy package
然后我在命令提示符下运行以下命令来安装 xmpppy 包
python -m pip install xmpppy
Next I created the following base.py file that uses the aforementioned xmpppy package接下来我创建了以下 base.py 文件,该文件使用上述 xmpppy 包
#!/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
Now when I run the command现在当我运行命令时
python base.py
in the folder that the base.py file exists I get the following error message:在 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'
In the folder C:\\Users\\AGO109\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages\\xmpp simplexml.py, protocol.py etc. all exist and the windows system variables contain the paths for python and packages, so what's the problem?在文件夹 C:\\Users\\AGO109\\AppData\\Local\\Programs\\Python\\Python37\\lib\\site-packages\\xmpp simplexml.py、protocol.py 等都存在并且 windows 系统变量包含 python 和包的路径, 所以有什么问题?
I'm facing same issue.我面临同样的问题。
Try installing each of the packages using command like pip install simplexml
and then run your code.尝试使用
pip install simplexml
类的命令安装每个包,然后运行您的代码。 Mine is stuck at installing transports
.我的卡在安装
transports
。
Alternately,you may try switching to using sleekxmpp
that comes bundled with your python installation.或者,您可以尝试切换到使用与您的 python 安装捆绑在一起的
sleekxmpp
。 As sleekxmpp
has latest version published in 2017 compared to that of 2006 for xmpppy
, i'm planning to stick with using sleekxmpp
library.由于与
sleekxmpp
的 2006 年版本相比, sleekxmpp
最新版本是 2017 年xmpppy
,因此我计划坚持使用sleekxmpp
库。 If you update your code to use sleekxmpp
as per the boilerplate code at https://pypi.org/project/sleekxmpp/ , XMPP connections work.如果您按照https://pypi.org/project/sleekxmpp/ 上的样板代码更新代码以使用
sleekxmpp
,则 XMPP 连接有效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.