Python Forum
ModuleNotFoundError: No module named ‘CommandNotFound’ - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: ModuleNotFoundError: No module named ‘CommandNotFound’ (/thread-24604.html)



ModuleNotFoundError: No module named ‘CommandNotFound’ - jiapei100 - Feb-22-2020

Whenever I try

Quote:sudo apt update

I got:

Quote:Traceback (most recent call last):
File "/usr/lib/cnf-update-db", line 8, in <module>
from CommandNotFound.db.creator import DbCreator
ModuleNotFoundError: No module named 'CommandNotFound'
Reading package lists... Done
E: Problem executing scripts APT::Update::Post-Invoke-Success 'if /usr/bin/test -w /var/lib/command-not-found/ -a -e /usr/lib/cnf-update-db; then /usr/lib/cnf-update-db > /dev/null; fi'
E: Sub-process returned an error code


Any suggestions?
Pei


RE: ModuleNotFoundError: No module named ‘CommandNotFound’ - Larz60+ - Feb-22-2020

command is:
sudo apt-get update


RE: ModuleNotFoundError: No module named ‘CommandNotFound’ - jiapei100 - Feb-22-2020

(Feb-22-2020, 03:34 AM)Larz60+ Wrote: command is:
sudo apt-get update

Well, yes... I'm using Ubuntu 18.04.3, in this version:
Quote:sudo apt update
is the same as
Quote:sudo apt-get update



RE: ModuleNotFoundError: No module named ‘CommandNotFound’ - snippsat - Feb-22-2020

Looking at your previous Thread.
This likely mess up most the PATH to original Python version.
If looking at Package: command-not-found
So here see that dependency is the default python3 version,this will be the same for the Debian family Ubuntu,Mint...ect.
Look here for possible solution's.

As a advice you should not at all mess with default Python installation in Linux.
Using alias is safer than mess with export.
My advice is using pyenv Simple Python Version Management


RE: ModuleNotFoundError: No module named ‘CommandNotFound’ - jiapei100 - Feb-22-2020

(Feb-22-2020, 10:05 AM)snippsat Wrote: My advice is using pyenv Simple Python Version Management

Quote:➜ ~ pyenv install -v 3.8.1
......
ERROR: Exception:
Traceback (most recent call last):
File "/tmp/tmp6a9wsa3z/pip-19.2.3-py2.py3-none-any.whl/pip/_internal/cli/base_command.py", line 188, in main
status = self.run(options, args)
File "/tmp/tmp6a9wsa3z/pip-19.2.3-py2.py3-none-any.whl/pip/_internal/commands/install.py", line 286, in run
with self._build_session(options) as session:
File "/tmp/tmp6a9wsa3z/pip-19.2.3-py2.py3-none-any.whl/pip/_internal/cli/base_command.py", line 101, in _build_session
session = PipSession(
File "/tmp/tmp6a9wsa3z/pip-19.2.3-py2.py3-none-any.whl/pip/_internal/download.py", line 559, in __init__
self.headers["User-Agent"] = user_agent()
File "/tmp/tmp6a9wsa3z/pip-19.2.3-py2.py3-none-any.whl/pip/_internal/download.py", line 144, in user_agent
zip(["name", "version", "id"], distro.linux_distribution()),
File "/tmp/tmp6a9wsa3z/pip-19.2.3-py2.py3-none-any.whl/pip/_vendor/distro.py", line 122, in linux_distribution
return _distro.linux_distribution(full_distribution_name)
File "/tmp/tmp6a9wsa3z/pip-19.2.3-py2.py3-none-any.whl/pip/_vendor/distro.py", line 677, in linux_distribution
self.version(),
File "/tmp/tmp6a9wsa3z/pip-19.2.3-py2.py3-none-any.whl/pip/_vendor/distro.py", line 737, in version
self.lsb_release_attr('release'),
File "/tmp/tmp6a9wsa3z/pip-19.2.3-py2.py3-none-any.whl/pip/_vendor/distro.py", line 899, in lsb_release_attr
return self._lsb_release_info.get(attribute, '')
File "/tmp/tmp6a9wsa3z/pip-19.2.3-py2.py3-none-any.whl/pip/_vendor/distro.py", line 552, in __get__
ret = obj.__dict__[self._fname] = self._f(obj)
File "/tmp/tmp6a9wsa3z/pip-19.2.3-py2.py3-none-any.whl/pip/_vendor/distro.py", line 1012, in _lsb_release_info
stdout = subprocess.check_output(cmd, stderr=devnull)
File "/tmp/python-build.20200222120905.3660/Python-3.8.1/Lib/subprocess.py", line 411, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/tmp/python-build.20200222120905.3660/Python-3.8.1/Lib/subprocess.py", line 512, in run
raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '('lsb_release', '-a')' died with <Signals.SIGABRT: 6>.
Makefile:1186: recipe for target 'install' failed
make: *** [install] Error 2

BUILD FAILEDCould not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007f597cccd340 (most recent call first):
( using python-build 1.2.16-5-g7097f820)

Inspect or clean up the working tree at /tmp/python-build.20200222120905.3660
Results logged to /tmp/python-build.20200222120905.3660.log

Last 10 log lines:
subprocess.CalledProcessError: Command '('lsb_release', '-a')' died with <Signals.SIGABRT: 6>.
Makefile:1186: recipe for target 'install' failed
make: *** [install] Error 2
Could not find platform independent libraries <prefix>
Could not find platform dependent libraries <exec_prefix>
Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>]
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007f597cccd340 (most recent call first):
➜ ~

Failed to install Python3.8.1 under pyenv


RE: ModuleNotFoundError: No module named ‘CommandNotFound’ - snippsat - Feb-22-2020

(Feb-22-2020, 08:13 PM)jiapei100 Wrote: ➜ ~ pyenv install -v 3.8.1
There is no -v when you install.
pyenv install 3.8.1
You use capital -V after to check version.
python -V
Python 3.8.1