python 的一个非常奇怪的问题

python 的一个非常奇怪的问题

首先,我对咖啡因有问题: 咖啡因在 Ubuntu 17.10 上不起作用

我没有用python绑定它。顺便说一句,在Xorg下运行ubuntu没有帮助。

其次,当我尝试测试 Python 程序时,我收到了奇怪的错误。我运行了

 python3 programname.py test

并收到

File "sampletest.py", line 1, in <module>
    import unittest
  File "/usr/lib/python3.6/unittest/__init__.py", line 59, in <module>
    from .case import (TestCase, FunctionTestCase, SkipTest, skip, skipIf,
  File "/usr/lib/python3.6/unittest/case.py", line 6, in <module>
    import logging
  File "/usr/lib/python3.6/logging/__init__.py", line 28, in <module>
    from string import Template
ImportError: cannot import name 'Template'
Error in sys.excepthook:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/apport_python_hook.py", line 63, in apport_excepthook
    from apport.fileutils import likely_packaged, get_recent_crashes
  File "/usr/lib/python3/dist-packages/apport/__init__.py", line 5, in <module>
    from apport.report import Report
  File "/usr/lib/python3/dist-packages/apport/report.py", line 21, in <module>
    from urllib.request import urlopen
  File "/usr/lib/python3.6/urllib/request.py", line 88, in <module>
    import http.client
  File "/usr/lib/python3.6/http/client.py", line 71, in <module>
    import email.parser
  File "/usr/lib/python3.6/email/parser.py", line 12, in <module>
    from email.feedparser import FeedParser, BytesFeedParser
  File "/usr/lib/python3.6/email/feedparser.py", line 27, in <module>
    from email._policybase import compat32
  File "/usr/lib/python3.6/email/_policybase.py", line 7, in <module>
    from email import header
  File "/usr/lib/python3.6/email/header.py", line 16, in <module>
    import email.quoprimime
  File "/usr/lib/python3.6/email/quoprimime.py", line 44, in <module>
    from string import ascii_letters, digits, hexdigits
ImportError: cannot import name 'ascii_letters'

然后我运行alacarte后收到错误:我如何按字母顺序对 Xfce 的 whisker 菜单列表进行排序?

顺便说一句,运行 menulibre 时我收到了类似的错误:

/usr/lib/python3/dist-packages/menulibre/MenuEditor.py:28: PyGIWarning: GMenu was imported without specifying a version first. Use gi.require_version('GMenu', '3.0') before import to ensure that the right version gets loaded.
  from gi.repository import GdkPixbuf, Gio, GLib, GMenu, Gtk
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/menulibre/MenulibreApplication.py", line 1717, in do_activate
    self.win = MenulibreWindow(self)
  File "/usr/lib/python3/dist-packages/menulibre/MenulibreApplication.py", line 207, in __init__
    self.configure_application_treeview(builder)
  File "/usr/lib/python3/dist-packages/menulibre/MenulibreApplication.py", line 462, in configure_application_treeview
    self.treeview = MenulibreTreeview.Treeview(self, builder)
  File "/usr/lib/python3/dist-packages/menulibre/MenulibreTreeview.py", line 43, in __init__
    self._configure_treeview(builder)
  File "/usr/lib/python3/dist-packages/menulibre/MenulibreTreeview.py", line 54, in _configure_treeview
    treestore = MenuEditor.get_treestore()
  File "/usr/lib/python3/dist-packages/menulibre/MenuEditor.py", line 113, in get_treestore
    menu = get_menus()[0]
  File "/usr/lib/python3/dist-packages/menulibre/MenuEditor.py", line 175, in get_menus
    menu = MenuEditor()
  File "/usr/lib/python3/dist-packages/menulibre/MenuEditor.py", line 227, in __init__
    self.load()
  File "/usr/lib/python3/dist-packages/menulibre/MenuEditor.py", line 245, in load
    if not self.tree.load_sync():
GLib.Error: g-markup-error-quark: Error on line 1 char 1: Document was empty or contained only whitespace (1)

我确定我的 Python 解释器有问题,但我不知道是什么问题。请帮忙

PS 我是 Linux 新手。所以,请尽可能简单地解释一下

PPS 我有 Ubuntu 17.10

答案1

对于menulibre部分,您应该重新安装它及其依赖项:

sudo apt-get update
sudo apt-get install --reinstall gir1.2-gmenu-3.0 gnome-menus libgnome-menu-3-0 menulibre

menulibre然后使用命令或菜单启动它。

相关内容