获取未知编码:idna然后无法在eclipse上的python PyDev插件中调试

时间:2018-02-28 07:06:46

标签: python eclipse pydev

同事为我提供了一组用于测试的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说“未使用导入”),但仍然得到相同的错误。所以我放了一些断点并开始调试,但调试器没有达到断点。程序termniates没有任何断点给出以下错误:

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 oxygen 4.7和PyDev 6.2.0.201711281614)

1 个答案:

答案 0 :(得分:0)

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

from matplotlib.rcsetup import interactive_bk, non_interactive_bk # @UnresolvedImport

失败了(如果安装了matplotlib,那么在PyDev中会出现这种情况)。

不确定为什么......我需要调查你是否有一个破坏的matplotlib或matplotlib是否实际发生了变化(在这种情况下需要修复pydev调试器)。

您可以在matplotlib版本上添加详细信息吗?