Python reported an error ModuleNotFoundError: No module named 'MySQLdb' in venv

< H2 > Environment < / H2 >
Win7Python 3.6.5,
< H2 > situation < / H2 >

there is import MySQLdb in the script that can be executed directly, but it is executed in the venv created with a failure prompt ModuleNotFoundError: No module named "MySQLdb" . Run pip install MySQLdb error message:


(prod) D:\mysite\crawler>python
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Inte
l)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()

(prod) D:\mysite\crawler>python parse_content.py
Traceback (most recent call last):
  File "parse_content.py", line 3, in <module>
    from model import article as article_model, \
  File "D:\mysite\crawler\model\__init__.py", line 3, in <module>
    import MySQLdb
ModuleNotFoundError: No module named "MySQLdb"


(prod) D:\mysite\crawler>pip install MySQLdb
Collecting MySQLdb
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None))
 after connection broken by "ReadTimeoutError("HTTPSConnectionPool(host="pypi.or
g", port=443): Read timed out. (read timeout=15)",)": /simple/mysqldb/
  Could not find a version that satisfies the requirement MySQLdb (from versions
: )
No matching distribution found for MySQLdb



(prod) D:\mysite\crawler>pip search mysqldb
mysqldb-rich (2.4)     - rich mysqldb
Flask-MySQLdb (0.2.0)  - MySQLdb extension for Flask
lurker (0.1)           - a tiny wrapper for mysqldb
mysqldbhelper (1.0.2)  - A simple wrapper over mysqldb
umysqldb (1.0.3)       - MySQLdb compatible wrapper for ultramysql
tomdb (0.5.1)          - A simple wrapper around MySQLdb and pymysql.
mandb (0.1.4)          - Mandb is a lightweight wrapper around MySQLdb and
                         sqlite3.
sqlShort (0.3)         - A tiny wrapper for the Python modules MySQLdb and
                         Sqlite
sqlwitch (0.2)         - sqlwitch offers idiomatic SQL generation on top of
                         MySQLdb.
simplemysql (1.25)     - An ultra simple wrapper for Python MySQLdb with very
                         basic functionality
torndb (0.3)           - A lightweight wrapper around MySQLdb.  Originally
                         part of the Tornado framework.
mysql_helper (1.0.0)   - Um mdulo para auxiliar operaes com o MySQL e
                         MySQLdb

(prod) D:\mysite\crawler>

Why do you quit venv and execute pip install MySQLdb , but then you can

?
Apr.29,2021

if the mistake you reported is this

 Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None))
 after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.or
g', port=443): Read timed out. (read timeout=15)",)': /simple/mysqldb/
  Could not find a version that satisfies the requirement MySQLdb (from versions
: )

you can try to increase the timeout

pip --default-timeout=100 install MySQLdb

personal suggestion to change the source (Tsinghua University), the speed will also be accelerated

pip install --index https://mirrors.ustc.edu.cn/pypi/web/simple/ virtualenv 

the package name is wrong.

in environments where MySQLdb can be imported, the package name can be found through the MySQLdb.__file__ attribute.

generally use pip install mysqlclient to install the module, while windows systems generally download binary installation files, eliminating the compilation process.

Please refer to python" rel=" nofollow noreferrer "> https://github.com/PyMySQL/my.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b30e87-2b59c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b30e87-2b59c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?