configparser.DuplicateOptionError: While reading from '<dict>': option 'socks_proxy' in section 'DEFAULT' already exists

configparser.DuplicateOptionError: While reading from '<dict>': option 'socks_proxy' in section 'DEFAULT' already exists

我有一个我无法解决的问题,我希望有人能给我提示哪里出了问题。

我必须在 SLES 服务器上安装 tabpy。我已经安装了 python-3.8.12、openssl-1.1.1l 和 tabpy 2.4.0。我通过了指令:https://tableau.github.io/TabPy/docs/server-install.html

不幸的是,当我 运行 tabpy 时,我收到以下错误消息:

    /infa/mgmt/pythons/python-3.8.12/bin> ./tabpy
Traceback (most recent call last):
  File "./tabpy", line 8, in <module>
    sys.exit(main())
  File "/infa/mgmt/pythons/python-3.8.12/lib/python3.8/site-packages/tabpy/tabpy.py", line 43, in main
    app = TabPyApp(config)
  File "/infa/mgmt/pythons/python-3.8.12/lib/python3.8/site-packages/tabpy/tabpy_server/app/app.py", line 76, in __init__
    self._parse_config(config_file)
  File "/infa/mgmt/pythons/python-3.8.12/lib/python3.8/site-packages/tabpy/tabpy_server/app/app.py", line 243, in _parse_config
    parser = configparser.ConfigParser(os.environ)
  File "/infa/mgmt/pythons/python-3.8.12/lib/python3.8/configparser.py", line 639, in __init__
    self._read_defaults(defaults)
  File "/infa/mgmt/pythons/python-3.8.12/lib/python3.8/configparser.py", line 1219, in _read_defaults
    self.read_dict({self.default_section: defaults})
  File "/infa/mgmt/pythons/python-3.8.12/lib/python3.8/configparser.py", line 752, in read_dict
    raise DuplicateOptionError(section, key, source)
configparser.DuplicateOptionError: While reading from '<dict>': option 'socks_proxy' in section 'DEFAULT' already exists

我用不同版本的 python(3.9.9 和 3.8.1)以及不同版本的 tabpy 进行了测试。错误信息总是一样的。

我也 运行 ./tabpy --config=infa/mgmt/pythons/python-3.8.12/bin/file.conf 我在 tabpy wiki 上提供了一个配置 - 问题是一样的。

如果有人知道哪里出了问题,或者能够指导我获得正确的知识,我会很感激的。

干杯!

我在 Pypy 3.8 中遇到了这个问题,并深入研究了代码以找到根本原因。
问题来自不同情况下的重复环境变量(http_proxy 和 HTTP_PROXY 在我的例子中)。这在 Linux 上通常完全没问题,并且可以与旧版本的 configparser 一起使用,但由于某种原因,它带有 pypy 扼流圈。

正如您在堆栈跟踪中看到的那样,您的 ConfigParser 实例将 os.environ 作为默认字典(这就是最后一行中的 所指的到)所以你可能有同样的问题。

尝试 unset socks_proxy 在 运行 你的命令之前。