是否有将 jaeger 4.0.0 与 pyinstaller(python3.7)一起使用的解决方法



不幸的是,我无法将PyInstaller与jaeger一起使用。问题是 PyInstaller 和 jaeger 之间的某种节俭错误。就像这里讨论的那样。

他们是否有任何解决方法或修复?

我已经用python 3.6和最新的jaeger-client尝试过了。在那里我得到一个 Errno 2 -> 即使我什至不使用配置文件

  exec(bytecode, module.__dict__)
  File "jaeger/__init__.py", line 17, in <module>
  File "jaeger/core/configuration.py", line 74, in get_config
FileNotFoundError: [Errno 2] No such file or directory: '/Users/.../PycharmProjects/untitled1/dist/app/jaeger/core/../etc/jaeger.yml'
[6348] Failed to execute script app
from quart import Quart
import uvicorn as uv
import logging
import time
from jaeger_client import Config
app = Quart(__name__)

@app.route('/')
async def root():
    return 'Hello world'
if __name__ == '__main__':
    log_level = logging.DEBUG
    logging.getLogger('').handlers = []
    logging.basicConfig(format='%(asctime)s %(message)s', level=log_level)
    config = Config(
        config={  # usually read from some yaml config
            'sampler': {
                'type': 'const',
                'param': 1,
            },
            'logging': True,
        },
        service_name='your-app-name',
        validate=True,
    )
    # this call also sets opentracing.tracer
    tracer = config.initialize_tracer()
    with tracer.start_span('TestSpan') as span:
        span.log_kv({'event': 'test message', 'life': 42})
        with tracer.start_span('ChildSpan', child_of=span) as child_span:
            span.log_kv({'event': 'down below'})
    time.sleep(
        2)  # yield to IOLoop to flush the spans - https://github.com/jaegertracing/jaeger-client-python/issues/50
    tracer.close()  # flush any buffered spans
    uv.run(app)

脚本按预期运行 -> 创建跨度并启动 Web 服务器。仅在可执行文件中,它不会运行。并显示以下错误:

  exec(bytecode, module.__dict__)
  File "jaeger/__init__.py", line 17, in <module>
  File "jaeger/core/configuration.py", line 74, in get_config
FileNotFoundError: [Errno 2] No such file or directory: '/Users/.../PycharmProjects/untitled1/dist/app/jaeger/core/../etc/jaeger.yml'
[6348] Failed to execute script app

似乎 PyInstaller 无法解析jaeger_client导入。因此,一个简单的方法是编辑您的 spec 文件并将整个jaeger_client库添加为Tree类:

# -*- mode: python -*-
block_cipher = None

a = Analysis(['script.py'],
             ...)
a.datas += Tree('<python_path>/Lib/site-packages/jaeger_client', prefix='./jaeger_client')
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
...

并使用pyinstaller script.spec生成可执行文件。

相关内容

  • 没有找到相关文章

最新更新