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

solve:

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 ✗
/usr/lib/python3.8/lib-dynload/_sqlite3.cpython-38-x86_64-linux-gnu.so
ubuntu@esoaru-net ~/github/aiopathlib
☺  which python3.9                                                                                                                                                  master ✗
/usr/local/bin/python3.9
ubuntu@esoaru-net ~/github/aiopathlib
☺  cp /usr/lib/python3.8/lib-dynload/_sqlite3.cpython-38-x86_64-linux-gnu.so /usr/lib/python3.9/lib-dynload/                                                        master ✗
cp: cannot create regular file '/usr/lib/python3.9/lib-dynload/_sqlite3.cpython-38-x86_64-linux-gnu.so': Permission denied
ubuntu@esoaru-net ~/github/aiopathlib
☹  sudo cp /usr/lib/python3.8/lib-dynload/_sqlite3.cpython-38-x86_64-linux-gnu.so /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 _sqlite3.cpython-38-x86_64-linux-gnu.so _sqlite3.cpython-39-x86_64-linux-gnu.so
ubuntu@esoaru-net /usr/lib/python3.9/lib-dynload
☺  python3.9 -c 'import _sqlite3;print(_sqlite3.__file__)'
/usr/lib/python3.9/lib-dynload/_sqlite3.cpython-39-x86_64-linux-gnu.so
☹  sudo cp /usr/lib/python3.9/lib-dynload/* /usr/local/lib/python3.9/lib-dynload/  

Summary:

It’s actually a line of command

sudo cp /usr/lib/python3.8/lib-dynload/_sqlite3.cpython-38-x86_64-linux-gnu.so /usr/lib/python3.9/lib-dynload/_sqlite3.cpython-39-x86_64-linux-gnu.so

Read More: