Search code examples
python-3.xpython-2.7amazon-athenapyathena

RuntimeError: Unable to start JVM because of Deprecated: convertStrings


I run an automated python job on an EMR cluster that updates Amazon Athena Tables.

It was running well until few days ago (on python 2.7 and 3.7). Here is the script:

from pyathenajdbc import connect
import yaml

config = yaml.load(open('athena-config.yaml', 'r'))
statements = config['statements']
staging_dir = config['staging_dir']

conn = connect(s3_staging_dir=staging_dir, region_name='eu-west-1')

try:
    with conn.cursor() as cursor:
        for statement in statements:
            cursor.execute(statement)
finally:
    conn.close()

The athena-config.yaml has a staging directory and few Athena Statements.

Here is the Error:

You are using pip version 9.0.3, however version 19.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Unrecognized option: -server
create_tables.py:5: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  config = yaml.load(open('athena-config.yaml', 'r'))
/mnt/conda/lib/python3.7/site-packages/jpype/_core.py:210: UserWarning: 
-------------------------------------------------------------------------------
Deprecated: convertStrings was not specified when starting the JVM. The default
behavior in JPype will be False starting in JPype 0.8. The recommended setting
for new code is convertStrings=False.  The legacy value of True was assumed for
this session. If you are a user of an application that reported this warning,
please file a ticket with the developer.
-------------------------------------------------------------------------------

  """)
Traceback (most recent call last):
  File "create_tables.py", line 10, in <module>
    region_name='eu-west-1')
  File "/mnt/conda/lib/python3.7/site-packages/pyathenajdbc/__init__.py", line 69, in connect
    driver_path, log4j_conf, **kwargs)
  File "/mnt/conda/lib/python3.7/site-packages/pyathenajdbc/connection.py", line 68, in __init__
    self._start_jvm(jvm_path, jvm_options, driver_path, log4j_conf)
  File "/mnt/conda/lib/python3.7/site-packages/pyathenajdbc/util.py", line 25, in _wrapper
    return wrapped(*args, **kwargs)
  File "/mnt/conda/lib/python3.7/site-packages/pyathenajdbc/connection.py", line 97, in _start_jvm
    jpype.startJVM(jvm_path, *args)
  File "/mnt/conda/lib/python3.7/site-packages/jpype/_core.py", line 219, in startJVM
    _jpype.startup(jvmpath, tuple(args), ignoreUnrecognized, convertStrings)
RuntimeError: Unable to start JVM
    at loadJVM(native/common/jp_env.cpp:169)
    at loadJVM(native/common/jp_env.cpp:179)
    at startup(native/python/pyjp_module.cpp:159)

As far as I understand the issue in convertStrings being deprecated. Can anyone help me resolve that? I cannot understand why this """) comes before the traceback, and what changed in past days to break the code. Thanks!


Solution

  • Got the same issue today. Try to downgrade JPype1 to 0.6.3. JPype1 released 0.7.0 today, which is not compatible with old interfaces.