Home > Enterprise >  (Linux , Python) still face `ModuleNotFoundError: No module named 'pymysql'` after pip ins
(Linux , Python) still face `ModuleNotFoundError: No module named 'pymysql'` after pip ins

Time:01-12

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

  • checking pip version
    that I also did uograde pip then unistall pymysql and mysql-connector-python, and install twice follow the discussion enter image description here

CodePudding user response:

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>

  • Related