ModuleNotFoundError in tracebacks with Python3.6 on linux
I made a string, using the new literal string interpolation, but I supplied an invalid format specifier. I not only got the expected ValueError: Invalid format specifier , but also the unexpected ModuleNotFoundError: No module named ‘apt_pkg’ .
$ python3.6 Python 3.6.0 (default, Dec 29 2016, 21:40:36) [GCC 5.4.1 20161202] on linux Type "help", "copyright", "credits" or "license" for more information. >>> value = 4 * 20 >>> f'the value is ' Traceback (most recent call last): File "", line 1, in ValueError: Invalid format specifier 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 from apport.report import Report File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in import apport.fileutils File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in from apport.packaging_impl import impl as packaging File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 23, in import apt File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in import apt_pkg ModuleNotFoundError: No module named 'apt_pkg' Original exception was: Traceback (most recent call last): File "", line 1, in ValueError: Invalid format specifier
It seems to be vendor’s issue not CPython itself. This same issue also happens in Ubuntu 16.10’s Python 3.6. Raise any exception can cause this:
Python 3.6.0b2 (default, Oct 11 2016, 05:27:10) [GCC 6.2.0 20161005] on linux Type "help", "copyright", "credits" or "license" for more information. >>> raise Exception Traceback (most recent call last): File "", line 1, in Exception 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 from apport.report import Report File "/usr/lib/python3/dist-packages/apport/report.py", line 30, in import apport.fileutils File "/usr/lib/python3/dist-packages/apport/fileutils.py", line 23, in from apport.packaging_impl import impl as packaging File "/usr/lib/python3/dist-packages/apport/packaging_impl.py", line 23, in import apt File "/usr/lib/python3/dist-packages/apt/__init__.py", line 23, in import apt_pkg ModuleNotFoundError: No module named 'apt_pkg' Original exception was: Traceback (most recent call last): File "", line 1, in Exception >>>
Yes, this appears to be the vendor’s failure reporting infrastructure that is failing. Why they’d want a report for every traceback at the interactive prompt is beyond me, but that appears to be what they are trying to do.
- How do I interpret this comment? Is the vendor in this case Jonathon Fernyhough’s PPA? And did he change something to to the Python code he distributes so that it tries to file a report for every Exception that produces a traceback?
- Who do I need to notify or where do I need to file a bug to get this resolved?
Решение проблемы со сломавшимся после обновления пакетов Pip
Процесс установки одной из программ завершился ошибкой, в логах я наблюдал следующее:
[+] Running the command: sudo -E pip install --upgrade termcolor Traceback (most recent call last): File "/usr/bin/pip", line 9, in load_entry_point('pip==1.5.6', 'console_scripts', 'pip')() File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 356, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2476, in load_entry_point return ep.load() File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2190, in load ['__name__']) File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 74, in from pip.vcs import git, mercurial, subversion, bazaar # noqa File "/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in from pip.download import path_to_url File "/usr/lib/python2.7/dist-packages/pip/download.py", line 25, in from requests.compat import IncompleteRead ImportError: cannot import name IncompleteRead [+] Running the command: sudo -E pip install --upgrade ndg-httpsclient Traceback (most recent call last): File "/usr/bin/pip", line 9, in load_entry_point('pip==1.5.6', 'console_scripts', 'pip')() File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 356, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2476, in load_entry_point return ep.load() File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2190, in load ['__name__']) File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 74, in from pip.vcs import git, mercurial, subversion, bazaar # noqa File "/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in from pip.download import path_to_url File "/usr/lib/python2.7/dist-packages/pip/download.py", line 25, in from requests.compat import IncompleteRead ImportError: cannot import name IncompleteRead [+] Running the command: sudo -E pip install --upgrade Ghost.py Traceback (most recent call last): File "/usr/bin/pip", line 9, in load_entry_point('pip==1.5.6', 'console_scripts', 'pip')() File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 356, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2476, in load_entry_point return ep.load() File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2190, in load ['__name__']) File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 74, in from pip.vcs import git, mercurial, subversion, bazaar # noqa File "/usr/lib/python2.7/dist-packages/pip/vcs/mercurial.py", line 9, in from pip.download import path_to_url File "/usr/lib/python2.7/dist-packages/pip/download.py", line 25, in from requests.compat import IncompleteRead ImportError: cannot import name IncompleteRead
Эта проблема распространённая и охватывает Kali Linux, Linux Mint, Ubuntu и, надо думать, все другие родственные дистрибутивы, включая Debian.
apt-get устанавливает очень старую версию pip, которая ведёт к проблемам. Решение очень простое — полное удаление python-pip, а затем установка вручную. Необходимые для этого команды (если нужно в вашей системе, то добавьте sudo):
apt-get remove python-pip wget https://bootstrap.pypa.io/get-pip.py python get-pip.py
apt-add-repository (Ошибка: Traceback (most recent call last))
Здравствуйте, появилась проблема, от куда и из-за чего не знаю, так как не видел по сих пор.
Система Linux Mint Cinnamon 17.2.
При попытке добавить какой либо репозиторий командой apt-add-repository или add-apt-repository (кстати если не трудно объясните в чем разница? А то так и не понял) получаю ошибку:
Traceback (most recent call last): File "/usr/lib/linuxmint/mintSources/mintSources.py", line 1387, in codename = config_parser.get("general", "base_codename") File "/usr/lib/python2.7/ConfigParser.py", line 330, in get raise NoSectionError(section)
Гугл сказал исправлять файл lsb-release, но что там исправлять я так и не понял, так как по мне там все правильно прописано, хотя могу ошибаться.
Содержание lsb-release:
DISTRIB_ID=Ubuntu DISTRIB_RELEASE=14.04 DISTRIB_CODENAME=trusty DISTRIB_DESCRIPTION="Ubuntu 14.04.3 LTS"
Плюс ко всему этому все что смог найти, это исправить /dev/debian_version на testing (До этого стоял jessie).
Результат пользы не принес, хотя это было понятно изначально.
Ошибка указывает на питон, хотя он у меня установлен. python-software-properties тоже (он вообще нужен? как установлен он не был, гугл сказал установить).
Кстати mint-ское приложение «Источники приложений» так же не запускается, пароль запрашивает после чего ничего не происходит. В какую сторону копать?
Why is this python error message generated whenever I type a nonsense command?
Whenever I type any «nonsense» command, this python error message is generated. Normal commands work fine. Any idea how to debug this?
$ somenonexistingcommand Traceback (most recent call last): File "/usr/local/lib/python2.7/site.py", line 553, in main() File "/usr/local/lib/python2.7/site.py", line 535, in main known_paths = addusersitepackages(known_paths) File "/usr/local/lib/python2.7/site.py", line 268, in addusersitepackages user_site = getusersitepackages() File "/usr/local/lib/python2.7/site.py", line 243, in getusersitepackages user_base = getuserbase() # this will also set USER_BASE File "/usr/local/lib/python2.7/site.py", line 233, in getuserbase USER_BASE = get_config_var('userbase') File "/usr/local/lib/python2.7/sysconfig.py", line 535, in get_config_var return get_config_vars().get(name) File "/usr/local/lib/python2.7/sysconfig.py", line 434, in get_config_vars _init_posix(_CONFIG_VARS) File "/usr/local/lib/python2.7/sysconfig.py", line 298, in _init_posix raise IOError(msg) IOError: invalid Python installation: unable to open /usr/include/python2.7/pyconfig.h (No such file or directory) $ echo this works fine, however this works fine, however $
$ yetanothernonexistingcommand Traceback (most recent call last): File "/usr/lib/command-not-found", line 10, in import CommandNotFound ImportError: No module named CommandNotFound