(Linux , Python) still face `ModuleNotFoundError: No module named 'pymysql'` after pip install

Question:

still face ModuleNotFoundError: No module named 'pymysql' after pip install

[root@localhost ~]# pip show pymysql
Name: PyMySQL
Version: 1.0.2
Summary: Pure Python MySQL Driver
Home-page: https://github.com/PyMySQL/PyMySQL/
Author: yutaka.matsubara
Author-email: [email protected]
License: "MIT"
Location: /usr/local/lib/python3.6/site-packages
Requires:
Required-by:
[root@localhost ~]# pip show mysql-connector-python
Name: mysql-connector-python
Version: 8.0.31
Summary: MySQL driver written in Python
Home-page: http://dev.mysql.com/doc/connector-python/en/index.html
Author: Oracle and/or its affiliates
Author-email:
License: GNU GPLv2 (with FOSS License Exception)
Location: /usr/local/lib/python3.6/site-packages
Requires: protobuf
Required-by:
[root@localhost ~]# pip list
Package                Version
---------------------- -------
mysql-connector        2.2.9
mysql-connector-python 8.0.31
pip                    21.3.1
protobuf               3.19.6
PyMySQL                1.0.2
setuptools             59.6.0

[root@localhost ~]# pip -V
pip 21.3.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)
[root@localhost ~]# pip3 -V
pip 21.3.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)

.html

<h> New product</h>


<p>content</p>

<html>
    <head>
      <link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css" />
      <script defer src="https://pyscript.net/latest/pyscript.js"></script>
    </head>
  <body>
    <b><p>title test 1.10-test_get_ print  </p></b>
    <br>


  
    <py-script>

      import pymysql
      print (pymysql.__version__)
      
      
    </py-script>
  </body>
</html>
  • website output
    enter image description here
Asked By: python coder

||

Answers:

You are using the PyScript framework, where the Python installation is on the server side of a third-party service and has nothing to do with your local Python installation.

You should therefore follow PyScript’s documentation of Importing the needed libraries to declare the libraries you wish to install with the py-config tag:

<html>
    <head>
      <link rel="stylesheet" href="https://pyscript.net/latest/pyscript.css" />
      <script defer src="https://pyscript.net/latest/pyscript.js"></script>
    </head>
  <body>
    <b><p>title test 1.10-test_get_ print  </p></b>
    <br>
    <py-config>
      packages = ["pymysql", "mysql-connector-python"]
    </py-config>
    <py-script>
      import pymysql
      print (pymysql.__version__)
    </py-script>
  </body>
</html>

Answered By: blhsing
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.