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

ubuntu@esoaru-net ~/github/aiopathlib
☺  python3.8 -c 'import _sqlite3;print(_sqlite3.__file__)'                                                                                                          master ✗
ubuntu@esoaru-net ~/github/aiopathlib
☺  which python3.9                                                                                                                                                  master ✗
ubuntu@esoaru-net ~/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
ubuntu@esoaru-net ~/github/aiopathlib
☹  sudo cp /usr/lib/python3.8/lib-dynload/ /usr/lib/python3.9/lib-dynload/                                                   master ✗
ubuntu@esoaru-net ~/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'
ubuntu@esoaru-net ~/github/aiopathlib
☹  cd /usr/lib/python3.9/lib-dynload                                                                                                                                master ✗
ubuntu@esoaru-net /usr/lib/python3.9/lib-dynload
☺  sudo mv
ubuntu@esoaru-net /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: