【问题标题】:Getting Unknown encoding: idna and then unable to debug in python PyDev plugin on eclipse获取未知编码:idna 然后无法在 eclipse 上的 python PyDev 插件中调试
【发布时间】:2018-08-07 23:48:52
【问题描述】:

同事为我提供了一组用于测试的 py 文件,这些文件在他的机器上运行良好。但是,当我运行 py 文件时,出现以下错误:

Traceback (most recent call last):
  File "D:\workspaces\pyworkspace\Analytics Python\python_server\server1.py", line 84, in <module>
    start_server()
  File "D:\workspaces\pyworkspace\Analytics Python\python_server\server1.py", line 57, in start_server
    socketObj.bind(server_address)
LookupError: unknown encoding: idna

Here,它说要添加import encodings.idna。所以我添加了那个导入(即使 eclipse 说“未使用的导入”),但仍然得到同样的错误。所以我放了一些断点并开始调试,但调试器没有命中断点。程序在没有遇到任何断点的情况下终止,并给出以下错误:

pydev debugger: starting (pid: 8316)
Traceback (most recent call last):
  File "_pydevd_bundle\pydevd_cython_win32_34_64.pyx", line 741, in _pydevd_bundle.pydevd_cython_win32_34_64.PyDBFrame.trace_dispatch (_pydevd_bundle/pydevd_cython_win32_34_64.c:15515)
  File "_pydevd_bundle\pydevd_cython_win32_34_64.pyx", line 254, in _pydevd_bundle.pydevd_cython_win32_34_64.PyDBFrame.do_wait_suspend (_pydevd_bundle/pydevd_cython_win32_34_64.c:5631)
  File "D:\Programs\Eclipse Oxygen\plugins\org.python.pydev_6.2.0.201711281614\pysrc\pydevd.py", line 764, in do_wait_suspend
    self._activate_mpl_if_needed()
  File "D:\Programs\Eclipse Oxygen\plugins\org.python.pydev_6.2.0.201711281614\pysrc\pydevd.py", line 416, in _activate_mpl_if_needed
    activate_function()
  File "D:\Programs\Eclipse Oxygen\plugins\org.python.pydev_6.2.0.201711281614\pysrc\pydevd.py", line 407, in <lambda>
    self.mpl_modules_for_patching = {"matplotlib": lambda: activate_matplotlib(do_enable_gui),
  File "D:\Programs\Eclipse Oxygen\plugins\org.python.pydev_6.2.0.201711281614\pysrc\pydev_ipython\matplotlibtools.py", line 93, in activate_matplotlib
    is_interactive = is_interactive_backend(backend)
  File "D:\Programs\Eclipse Oxygen\plugins\org.python.pydev_6.2.0.201711281614\pysrc\pydev_ipython\matplotlibtools.py", line 56, in is_interactive_backend
    from matplotlib.rcsetup import interactive_bk, non_interactive_bk  # @UnresolvedImport
ImportError: cannot import name 'interactive_bk'
Traceback (most recent call last):
  File "D:\Programs\Eclipse Oxygen\plugins\org.python.pydev_6.2.0.201711281614\pysrc\pydevd.py", line 1621, in <module>
    main()
  File "D:\Programs\Eclipse Oxygen\plugins\org.python.pydev_6.2.0.201711281614\pysrc\pydevd.py", line 1615, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "D:\Programs\Eclipse Oxygen\plugins\org.python.pydev_6.2.0.201711281614\pysrc\pydevd.py", line 1022, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "D:\Programs\Eclipse Oxygen\plugins\org.python.pydev_6.2.0.201711281614\pysrc\_pydev_imps\_pydev_execfile.py", line 25, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "D:\Mahesh\workspaces\pyworkspace\Analytics Python\python_server\server.py", line 84, in <module>
    start_server()
  File "D:\Mahesh\workspaces\pyworkspace\Analytics Python\python_server\server.py", line 84, in <module>
    start_server()
  File "_pydevd_bundle\pydevd_cython_win32_34_64.pyx", line 982, in _pydevd_bundle.pydevd_cython_win32_34_64.SafeCallWrapper.__call__ (_pydevd_bundle/pydevd_cython_win32_34_64.c:19346)
  File "_pydevd_bundle\pydevd_cython_win32_34_64.pyx", line 498, in _pydevd_bundle.pydevd_cython_win32_34_64.PyDBFrame.trace_dispatch (_pydevd_bundle/pydevd_cython_win32_34_64.c:18639)
  File "_pydevd_bundle\pydevd_cython_win32_34_64.pyx", line 750, in _pydevd_bundle.pydevd_cython_win32_34_64.PyDBFrame.trace_dispatch (_pydevd_bundle/pydevd_cython_win32_34_64.c:15669)
  File "_pydevd_bundle\pydevd_cython_win32_34_64.pyx", line 741, in _pydevd_bundle.pydevd_cython_win32_34_64.PyDBFrame.trace_dispatch (_pydevd_bundle/pydevd_cython_win32_34_64.c:15515)
  File "_pydevd_bundle\pydevd_cython_win32_34_64.pyx", line 254, in _pydevd_bundle.pydevd_cython_win32_34_64.PyDBFrame.do_wait_suspend (_pydevd_bundle/pydevd_cython_win32_34_64.c:5631)
  File "D:\Programs\Eclipse Oxygen\plugins\org.python.pydev_6.2.0.201711281614\pysrc\pydevd.py", line 764, in do_wait_suspend
    self._activate_mpl_if_needed()
  File "D:\Programs\Eclipse Oxygen\plugins\org.python.pydev_6.2.0.201711281614\pysrc\pydevd.py", line 416, in _activate_mpl_if_needed
    activate_function()
  File "D:\Programs\Eclipse Oxygen\plugins\org.python.pydev_6.2.0.201711281614\pysrc\pydevd.py", line 407, in <lambda>
    self.mpl_modules_for_patching = {"matplotlib": lambda: activate_matplotlib(do_enable_gui),
  File "D:\Programs\Eclipse Oxygen\plugins\org.python.pydev_6.2.0.201711281614\pysrc\pydev_ipython\matplotlibtools.py", line 93, in activate_matplotlib
    is_interactive = is_interactive_backend(backend)
  File "D:\Programs\Eclipse Oxygen\plugins\org.python.pydev_6.2.0.201711281614\pysrc\pydev_ipython\matplotlibtools.py", line 56, in is_interactive_backend
    from matplotlib.rcsetup import interactive_bk, non_interactive_bk  # @UnresolvedImport
ImportError: cannot import name 'interactive_bk'

为什么会这样? (我正在使用 python 3.4、eclipse 氧气 4.7 和 PyDev 6.2.0.201711281614)

【问题讨论】:

    标签: python eclipse pydev


    【解决方案1】:

    显然问题是因为 pydev 期望 matplotlib 有一些在您的安装中不可用的模块......所以,导入:

    from matplotlib.rcsetup import interactive_bk, non_interactive_bk # @UnresolvedImport

    失败(如果您安装了 matplotlib,这在 PyDev 中是预期的)。

    不知道为什么...我需要调查一下您的 matplotlib 是否损坏,或者 matplotlib 是否确实发生了变化(在这种情况下,需要修复 pydev 调试器)。

    您可以添加有关您拥有的 matplotlib 版本的详细信息吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-05-06
      • 2015-02-27
      • 1970-01-01
      • 2019-04-08
      • 2011-02-11
      • 1970-01-01
      • 2021-08-11
      • 2014-05-12
      相关资源
      最近更新 更多