Error no module named ‘in newly installed Python_ sqlite3‘

Tencent cloud server Ubuntu 20 already has Python 3.8. Download the installation package from Huawei cloud. After installing Python 3.9, an error is reported


Copy the dependent files from the existing 3.8 to 3.9, and then rename them. The command is as follows

[email protected] ~/github/aiopathlib
☺  python3.8 -c 'import _sqlite3;print(_sqlite3.__file__)'                                                                                                          master ✗
[email protected] ~/github/aiopathlib
☺  which python3.9                                                                                                                                                  master ✗
[email protected] ~/github/aiopathlib
☺  cp /usr/lib/python3.8/lib-dynload/ /usr/lib/python3.9/lib-dynload/                                                        master ✗
cp: cannot create regular file '/usr/lib/python3.9/lib-dynload/': Permission denied
[email protected] ~/github/aiopathlib
☹  sudo cp /usr/lib/python3.8/lib-dynload/ /usr/lib/python3.9/lib-dynload/                                                   master ✗
[email protected] ~/github/aiopathlib
☺  python3.9 -c 'import _sqlite3;print(_sqlite3.__file__)'                                                                                                          master ✗
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ModuleNotFoundError: No module named '_sqlite3'
[email protected]esoaru-net ~/github/aiopathlib
☹  cd /usr/lib/python3.9/lib-dynload                                                                                                                                master ✗
[email protected] /usr/lib/python3.9/lib-dynload
☺  sudo mv
[email protected] /usr/lib/python3.9/lib-dynload
☺  python3.9 -c 'import _sqlite3;print(_sqlite3.__file__)'
☹  sudo cp /usr/lib/python3.9/lib-dynload/* /usr/local/lib/python3.9/lib-dynload/  


It’s actually a line of command

sudo cp /usr/lib/python3.8/lib-dynload/ /usr/lib/python3.9/lib-dynload/

Read More: