【问题标题】:Error when running Python3 command in Ubuntu server?在 Ubuntu 服务器中运行 Python3 命令时出错?
【发布时间】:2019-10-17 00:53:58
【问题描述】:

我正在尝试使用命令 ($ 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)

【问题讨论】:

    标签: python apache-kafka


    【解决方案1】:

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

    你可以安装它:

    pip install confluent-kafka
    

    如here所述。

    【讨论】:

      猜你喜欢
      • 2015-09-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-20
      • 2012-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多