yurishkuro / opentracing-tutorial

A collection of tutorials for the OpenTracing API
Apache License 2.0
1.57k stars 404 forks source link

Python tutorial ImportError: No module named concurrent.futures #23

Closed flands closed 6 years ago

flands commented 6 years ago

I attempted to follow the Python tutorial, but am unable to get lesson1 to work following the directions provided.

pip install -r requirements.txt
mkdir lesson01/exercise
touch lesson01/exercise/__init__.py
...
python -m lesson01.exercise.hello Steve
Traceback (most recent call last):
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
  File "/Users/flands/sandbox/opentracing-tutorial/python/lesson01/exercise/hello.py", line 5, in <module>
    from jaeger_client import Config
  File "/Users/flands/.venv/python2/lib/python2.7/site-packages/jaeger_client/__init__.py", line 27, in <module>
    from .config import Config  # noqa
  File "/Users/flands/.venv/python2/lib/python2.7/site-packages/jaeger_client/config.py", line 24, in <module>
    from .local_agent_net import LocalAgentSender
  File "/Users/flands/.venv/python2/lib/python2.7/site-packages/jaeger_client/local_agent_net.py", line 17, in <module>
    from threadloop import ThreadLoop
  File "/Users/flands/.venv/python2/lib/python2.7/site-packages/threadloop/__init__.py", line 3, in <module>
    from threadloop.threadloop import ThreadLoop  # noqa
  File "/Users/flands/.venv/python2/lib/python2.7/site-packages/threadloop/threadloop.py", line 4, in <module>
    from concurrent.futures import Future
ImportError: No module named concurrent.futures

Solution appears to be adding futures to the requirements file -- I will submit a pull request shortly.

yurishkuro commented 6 years ago

Adding futures will break the requirements.txt for Python 3.x.

Jaeger lib already includes it for python < 3: https://github.com/jaegertracing/jaeger-client-python/blob/758cd14ac00679bcf8fb37c53f546a694b34e987/setup.py#L51

flands commented 6 years ago

Interesting -- any idea why it is not working then? future gets installed, but not futures

Successfully built opentracing jaeger-client opentracing-instrumentation thrift tornado future wrapt itsdangerous MarkupSafe
Installing collected packages: opentracing, six, singledispatch, certifi, backports-abc, tornado, threadloop, thrift, jaeger-client, future, wrapt, contextlib2, opentracing-instrumentation, chardet, urllib3, idna, requests, MarkupSafe, Jinja2, itsdangerous, Werkzeug, click, flask
Successfully installed Jinja2-2.10 MarkupSafe-1.0 Werkzeug-0.14.1 backports-abc-0.5 certifi-2018.4.16 chardet-3.0.4 click-6.7 contextlib2-0.5.5 flask-1.0.2 future-0.16.0 idna-2.7 itsdangerous-0.24 jaeger-client-3.10.0 opentracing-1.3.0 opentracing-instrumentation-2.4.1 requests-2.19.1 singledispatch-3.4.0.3 six-1.11.0 threadloop-1.0.2 thrift-0.11.0 tornado-4.5.3 urllib3-1.23 wrapt-1.10.11

futures is not listed as a requirement:

$ > python -V
Python 2.7.10
$ > pip --version
pip 10.0.1 from /Users/flands/.venv/python2/lib/python2.7/site-packages/pip (python 2.7)
$> pip show jaeger-client
Name: jaeger-client
Version: 3.10.0
Summary: Jaeger Python OpenTracing Tracer implementation
Home-page: https://github.com/jaegertracing/jaeger-client-python
Author: Yuri Shkuro
Author-email: ys@uber.com
License: Apache License 2.0
Location: /Users/flands/.venv/python2/lib/python2.7/site-packages
Requires: thrift, tornado, threadloop, opentracing
Required-by:
yurishkuro commented 6 years ago

which version of setuptools are you using? I think the older versions did not support the syntax

flands commented 6 years ago

Latest (see below). Appears syntax should be valid though sounds like direction is to move out of extra section. I have been playing with this and cannot determine why it is not working. I did confirm that futures can be added to the requirements file and only be applied to python_version < 3. Updating pull request as a workaround.

Package                     Version
--------------------------- ---------
appdirs                     1.4.3
backports-abc               0.5
certifi                     2018.4.16
chardet                     3.0.4
click                       6.7
contextlib2                 0.5.5
Flask                       1.0.2
future                      0.16.0
idna                        2.7
itsdangerous                0.24
jaeger-client               3.10.0
Jinja2                      2.10
MarkupSafe                  1.0
opentracing                 1.3.0
opentracing-instrumentation 2.4.1
packaging                   17.1
pip                         10.0.1
pyparsing                   2.2.0
requests                    2.19.1
setuptools                  40.0.0
singledispatch              3.4.0.3
six                         1.11.0
threadloop                  1.0.2
thrift                      0.11.0
tornado                     4.5.3
urllib3                     1.23
Werkzeug                    0.14.1
wheel                       0.31.1
wrapt                       1.10.11