1

I am trying to use https://github.com/dowjones/dj-dna-streams-python/tree/master/dnaStreaming . It's a package to receive news streams from Dow Jones. When I try to "listen" to the streams I receive the following error:

    ---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-36-372f4305a9e1> in <module>()
      1 while True:
----> 2     listener.listen(callback, maximum_messages=4, subscription_id=subscription_id)

~\AppData\Local\Continuum\Anaconda3\lib\site-packages\dj_dna_streaming_python-1.0.10-py3.5.egg\dnaStreaming\listener.py in listen(self, on_message_callback, maximum_messages, subscription_id)
     21     def listen(self, on_message_callback, maximum_messages=DEFAULT_UNLIMITED_MESSAGES, subscription_id=None):
     22         limit_pull_calls = not (maximum_messages == self.DEFAULT_UNLIMITED_MESSAGES)
---> 23         pubsub_client = pubsub_service.get_client(self.config)
     24 
     25         subscription_id = subscription_id if subscription_id is not None else self.config.subscription()

~\AppData\Local\Continuum\Anaconda3\lib\site-packages\dj_dna_streaming_python-1.0.10-py3.5.egg\dnaStreaming\services\pubsub_service.py in get_client(config)
      7 
      8 
----> 9 def get_client(config):
     10     streaming_credentials = credentials_service.fetch_credentials(config)
     11     credentials = authentication_service.get_authenticated_oauth_credentials(streaming_credentials)

~\AppData\Local\Continuum\Anaconda3\lib\site-packages\dj_dna_streaming_python-1.0.10-py3.5.egg\dnaStreaming\services\credentials_service.py in fetch_credentials(config)
     11     response = _get_requests().get(config.credentials_uri(), headers=headers)
     12 
---> 13     streaming_credentials_string = json.loads(response.text)['data']['attributes']['streaming_credentials']
     14 
     15     return json.loads(streaming_credentials_string)

~\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\models.py in text(self)
    824 
    825         self._content_consumed = True
--> 826         # don't need to release the connection; that's been handled by urllib3
    827         # since we exhausted the data.
    828         return self._content

~\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\models.py in apparent_encoding(self)
    694         is **not** a check to see if the response code is ``200 OK``.
    695         """
--> 696         try:
    697             self.raise_for_status()
    698         except HTTPError:

~\AppData\Local\Continuum\Anaconda3\lib\site-packages\requests\packages\chardet\__init__.py in detect(aBuf)

ImportError: cannot import name 'universaldetector'

I understand that the key part is that I can't import universaldetector. Any idea why is that? I have seen this answer but can't really relate to my problem. I have upgraded chardet and requests.

I am on Python3 and win . Executing code in Jupyter Notebook.

pawelty
  • 1,000
  • 8
  • 27

0 Answers0