Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tuple index out of range when importing mordecai #76

Closed
Jingnan92 opened this issue Feb 10, 2020 · 6 comments
Closed

Tuple index out of range when importing mordecai #76

Jingnan92 opened this issue Feb 10, 2020 · 6 comments

Comments

@Jingnan92
Copy link

Hello, I follow the instruction to import mordecai and keep getting the error (IndexError: tuple index out of range). Do you have any idea about this? Thanks.

@ahalterman
Copy link
Member

Can you provide some more details about when it's happening? Does the error message tell you which line is generating the error? It's possible that you have a mis-match between the version of spaCy that Mordecai requires and the latest (see #69, which I haven't forgotten about but haven't had time to get to)

@Jingnan92
Copy link
Author

Jingnan92 commented Feb 10, 2020

Thanks for your quick reply. Actually, the error information directs me to exceptions.py line 44.
And I am using Python3.7

@ahalterman
Copy link
Member

Which version of spaCy are you using?

@kmcdono2
Copy link

Hello - I'm having the same error (code below from my notebook). I have the following python/spacy installs:

spaCy version 2.0.18
Location /opt/anaconda3/lib/python3.7/site-packages/spacy
Platform Darwin-19.4.0-x86_64-i386-64bit
Python version 3.7.4
Models en_core_web_lg

Is this fixable?
Thanks!

geo = Geoparser()

GET http://localhost:9200/geonames/_count [status:404 request:0.171s]
---------------------------------------------------------------------------
NotFoundError                             Traceback (most recent call last)
/opt/anaconda3/lib/python3.7/site-packages/mordecai/geoparse.py in __init__(self, es_hosts, es_port, es_ssl, es_auth, verbose, country_threshold, threads, progress, mod_date, **kwargs)
     63             # with nostderr():
---> 64             self.conn.count()
     65         except:

/opt/anaconda3/lib/python3.7/site-packages/elasticsearch_dsl/search.py in count(self)
    586             body=d,
--> 587             **self._params
    588         )['count']

/opt/anaconda3/lib/python3.7/site-packages/elasticsearch/client/utils.py in _wrapped(*args, **kwargs)
     72                     params[p] = kwargs.pop(p)
---> 73             return func(*args, params=params, **kwargs)
     74         return _wrapped

/opt/anaconda3/lib/python3.7/site-packages/elasticsearch/client/__init__.py in count(self, index, doc_type, body, params)
   1122         return self.transport.perform_request('GET', _make_path(index,
-> 1123             doc_type, '_count'), params=params, body=body)
   1124 

/opt/anaconda3/lib/python3.7/site-packages/elasticsearch/transport.py in perform_request(self, method, url, params, body)
    311             try:
--> 312                 status, headers, data = connection.perform_request(method, url, params, body, ignore=ignore, timeout=timeout)
    313 

/opt/anaconda3/lib/python3.7/site-packages/elasticsearch/connection/http_urllib3.py in perform_request(self, method, url, params, body, timeout, ignore)
    127             self.log_request_fail(method, full_url, url, body, duration, response.status, raw_data)
--> 128             self._raise_error(response.status, raw_data)
    129 

/opt/anaconda3/lib/python3.7/site-packages/elasticsearch/connection/base.py in _raise_error(self, status_code, raw_data)
    124 
--> 125         raise HTTP_EXCEPTIONS.get(status_code, TransportError)(status_code, error_message, additional_info)
    126 

NotFoundError: TransportError(404, 'index_not_found_exception', 'no such index')

During handling of the above exception, another exception occurred:

ConnectionError                           Traceback (most recent call last)
/opt/anaconda3/lib/python3.7/site-packages/IPython/core/interactiveshell.py in run_code(self, code_obj, result, async_)
   3325                 else:
-> 3326                     exec(code_obj, self.user_global_ns, self.user_ns)
   3327             finally:

<ipython-input-3-f5392bd4d871> in <module>
----> 1 geo = Geoparser()

/opt/anaconda3/lib/python3.7/site-packages/mordecai/geoparse.py in __init__(self, es_hosts, es_port, es_ssl, es_auth, verbose, country_threshold, threads, progress, mod_date, **kwargs)
     69 See https://github.com/openeventdata/mordecai#installation-and-requirements
---> 70 for instructions on setting up Geonames/Elasticsearch""".format(es_hosts, es_port))
     71         es_date = utilities.check_geonames_date(self.conn)

<class 'str'>: (<class 'IndexError'>, IndexError('tuple index out of range'))

During handling of the above exception, another exception occurred:

IndexError                                Traceback (most recent call last)
/opt/anaconda3/lib/python3.7/site-packages/IPython/core/interactiveshell.py in run_code(self, code_obj, result, async_)
   3341             if result is not None:
   3342                 result.error_in_exec = sys.exc_info()[1]
-> 3343             self.showtraceback(running_compiled_code=True)
   3344         else:
   3345             outflag = False

/opt/anaconda3/lib/python3.7/site-packages/IPython/core/interactiveshell.py in showtraceback(self, exc_tuple, filename, tb_offset, exception_only, running_compiled_code)
   2043                                             value, tb, tb_offset=tb_offset)
   2044 
-> 2045                     self._showtraceback(etype, value, stb)
   2046                     if self.call_pdb:
   2047                         # drop into debugger

/opt/anaconda3/lib/python3.7/site-packages/ipykernel/zmqshell.py in _showtraceback(self, etype, evalue, stb)
    544             u'traceback' : stb,
    545             u'ename' : unicode_type(etype.__name__),
--> 546             u'evalue' : py3compat.safe_unicode(evalue),
    547         }
    548 

/opt/anaconda3/lib/python3.7/site-packages/ipython_genutils/py3compat.py in safe_unicode(e)
     63     """
     64     try:
---> 65         return unicode_type(e)
     66     except UnicodeError:
     67         pass

/opt/anaconda3/lib/python3.7/site-packages/elasticsearch/exceptions.py in __str__(self)
     67     def __str__(self):
     68         return 'ConnectionError(%s) caused by: %s(%s)' % (
---> 69             self.error, self.info.__class__.__name__, self.info)
     70 
     71 

/opt/anaconda3/lib/python3.7/site-packages/elasticsearch/exceptions.py in error(self)
     42     def error(self):
     43         """ A string error message. """
---> 44         return self.args[1]
     45 
     46     @property

IndexError: tuple index out of range

@ahalterman
Copy link
Member

Thanks for the full traceback! It's not a very informative error message, but it's telling you that it can't reach the Elasticsearch index. Are you sure it's up and running?

@kmcdono2
Copy link

Ah! I got it working. Yes, I think stopping and restarting Docker was the trick. Sorry for the bother.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants