zoukankan      html  css  js  c++  java
  • python 版本 jaeger-client 导入失败 jaeger-client-python

    环境为:

    OS: ubuntu18.04

    Python: 3.6

    问题原因:

    尝试使用 jaeger-client-python,官方给出的示例(https://github.com/jaegertracing/jaeger-client-python ReadMe文件中所述),出现了下面错误

    Traceback (most recent call last):
      File "jaeger.py", line 3, in <module>
        from jaeger_client import Config
      File "/usr/local/lib/python3.6/dist-packages/jaeger_client/__init__.py", line 27, in <module>
        from .config import Config  # noqa
      File "/usr/local/lib/python3.6/dist-packages/jaeger_client/config.py", line 26, in <module>
        from .reporter import (
      File "/usr/local/lib/python3.6/dist-packages/jaeger_client/reporter.py", line 32, in <module>
        from jaeger_client.thrift_gen.agent import Agent
      File "/usr/local/lib/python3.6/dist-packages/jaeger_client/thrift_gen/agent/Agent.py", line 13, in <module>
        from .ttypes import *
      File "/usr/local/lib/python3.6/dist-packages/jaeger_client/thrift_gen/agent/ttypes.py", line 12, in <module>
        import jaeger.ttypes
      File "/mnt/d/code/doc2/13_jaeger/jaeger.py", line 3, in <module>
        from jaeger_client import Config
    ImportError: cannot import name 'Config'  

    经过查找发现是在 thrift 生成的文件中导入包出错

    解决方案:重新打包 .whl 安装包

    step1:下载 jaeger-client-python 源码

    step2:修改代码如下

    文件1:./jaeger_client/thrift_gen/agent/ttypes.py 中,找到

    import jaeger.ttypes
    

    修改为:

    from jaeger_client.thrift_gen.jaeger import ttypes as jaeger_ttypes

    文件2:./jaeger_client/thrift_gen/agent/Agent.py 中,找到

    ...
      thrift_spec = (
        None, # 0
        (1, TType.STRUCT, 'batch', (jaeger.ttypes.Batch, jaeger.ttypes.Batch.thrift_spec), None, ), # 1
      )
    ...
    
          if fid == 1:
            if ftype == TType.STRUCT:
              self.batch = jaeger.ttypes.Batch()
              self.batch.read(iprot)
            else:
    ...
    

    修改其中的 jaeger.ttypes 为 jaeger_ttypes

    step3:在代码根目录下执行编译 

    python3 setup.py sdist bdist_wheel

    完成后,生成的文件在 ./dist 下面,有 .whl 和 tgz 两种格式

  • 相关阅读:
    3.2.2.5 BRE运算符优先级
    随机场(Random field)
    D-Separation(D分离)-PRML-8.22-Graphical Model 五 18 by 小军
    CVPR 2013 关于图像/场景分类(classification)的文章paper list
    Introduction to One-class Support Vector Machines
    SVM学习资料
    MIT牛人解说数学体系
    牛顿法与拟牛顿法学习笔记(五)L-BFGS 算法
    牛顿法与拟牛顿法学习笔记(四)BFGS 算法
    牛顿法与拟牛顿法学习笔记(三)DFP 算法
  • 原文地址:https://www.cnblogs.com/newguy/p/11804998.html
Copyright © 2011-2022 走看看