繁体   English   中英

在 Ubuntu 服务器中运行 Python3 命令时出错?

[英]Error when running Python3 command in Ubuntu server?

我正在尝试使用命令($ python3 es7.py)在 Ubuntu 服务器中运行 python 命令。 但是得到了错误(ModuleNotFoundError: No module named 'confluent_kafka')。

我的 es7.py 脚本

from confluent_kafka import Producer
import json
import requests
import time
p = Producer({"bootstrap_servers": "localhost:9092"})
while True:
    response1 = requests.get("http://api.openweathermap.org/data/2.5/weather?q=jaipur&appid=**")
    p.produce('weather', key='jaipur', value=response1.text)

您似乎没有在 ubuntu 服务器上安装必要的依赖项(confluent_kafka)。 先安装它。

您可以使用以下方式安装它:

pip install confluent-kafka

如此所述。

暂无
暂无

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

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