【问题标题】:RuntimeError: Unable to start JVM because of Deprecated: convertStringsRuntimeError: Unable to start JVM because of Deprecated: convertStrings
【发布时间】:2019-06-25 13:01:24
【问题描述】:

我在更新 Amazon Athena 表的 EMR 集群上运行了一个自动化的 Python 作业。

直到几天前它运行良好(在 python 2.7 和 3.7 上)。这是脚本:

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()

athena-config.yaml 有一个暂存目录和一些 Athena 语句。

这是错误:

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)

据我了解,convertStrings 被弃用的问题。谁能帮我解决这个问题?我不明白为什么这个""") 出现在回溯之前,以及过去几天发生了什么改变来破坏代码。谢谢!

【问题讨论】:

  • 我认为Unrecognized option: -server这是实际错误
  • 但我没有在任何地方指定 -server
  • 它可能来自图书馆。检查库的兼容版本和您拥有的 JVM 版本

标签: python-3.x python-2.7 amazon-athena pyathena


【解决方案1】:

今天遇到了同样的问题。尝试将 JPype1 降级到 0.6.3。 JPype1今天发布了0.7.0,不兼容旧接口。

【讨论】:

    【解决方案2】:

    问题似乎是程序包正在使用无法识别的参数 -server 调用 JVM。以前的版本忽略了那些允许事情继续进行的错误。要在 0.7.0 中获得相同的行为,需要将标志 ignoreUnrecognized 设置为 True。可能需要将其发送到pyathenajdbc 以纠正将虚假参数首先放入startJVM 的缺陷。

    查看源代码,-server 被硬编码到模块中。

    if not jpype.isJVMStarted():
                _logger.debug('JVM path: %s', jvm_path)
                args = [
                    '-server',
                    '-Djava.class.path={0}'.format(driver_path),
                    '-Dlog4j.configuration=file:{0}'.format(log4j_conf)
                ]
                if jvm_options:
                    args.extend(jvm_options)
                _logger.debug('JVM args: %s', args)
                jpype.startJVM(jvm_path, *args)
                cls.class_loader = jpype.java.lang.Thread.currentThread().getContextClassLoader()
    

    假设一个特定的 JVM 接受 -server 作为参数。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-01-05
      • 1970-01-01
      • 2022-12-26
      • 2022-11-12
      • 2014-02-08
      • 1970-01-01
      • 2011-10-15
      • 1970-01-01
      相关资源
      最近更新 更多