Python系列 | Python3.5安装MysqlClient教程

Python3.5安装MysqlClient

直接使用命令cmd输入:

pip install mysqlclient

报错如下:

D:\Program Files\PyCharm\project>pip install mysqlclient
DEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21
.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove support for this functionality.
Collecting mysqlclient
  Downloading mysqlclient-2.1.0.tar.gz (87 kB)
     |████████████████████████████████| 87 kB 122 kB/s
Building wheels for collected packages: mysqlclient
  Building wheel for mysqlclient (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'd:\program files\python\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\23587\\AppData\\Local\\Temp\\
pip-install-hhfby_h8\\mysqlclient_9af4676749d042b0bbe34570ebed338e\\setup.py'"'"'; __file__='"'"'C:\\Users\\23587\\AppData\\Local\\Temp\\pip-install-
hhfby_h8\\mysqlclient_9af4676749d042b0bbe34570ebed338e\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'
\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\23587\AppData\Local\Temp\pip-wheel-3n2oukw
v'
       cwd: C:\Users\23587\AppData\Local\Temp\pip-install-hhfby_h8\mysqlclient_9af4676749d042b0bbe34570ebed338e\
  Complete output (25 lines):
  d:\program files\python\lib\distutils\dist.py:261: UserWarning: Unknown distribution option: 'long_description_content_type'
    warnings.warn(msg)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.5
  creating build\lib.win-amd64-3.5\MySQLdb
  copying MySQLdb\__init__.py -> build\lib.win-amd64-3.5\MySQLdb
  copying MySQLdb\_exceptions.py -> build\lib.win-amd64-3.5\MySQLdb
  copying MySQLdb\connections.py -> build\lib.win-amd64-3.5\MySQLdb
  copying MySQLdb\converters.py -> build\lib.win-amd64-3.5\MySQLdb
  copying MySQLdb\cursors.py -> build\lib.win-amd64-3.5\MySQLdb
  copying MySQLdb\release.py -> build\lib.win-amd64-3.5\MySQLdb
  copying MySQLdb\times.py -> build\lib.win-amd64-3.5\MySQLdb
  creating build\lib.win-amd64-3.5\MySQLdb\constants
  copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-3.5\MySQLdb\constants
  copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.5\MySQLdb\constants
  copying MySQLdb\constants\CR.py -> build\lib.win-amd64-3.5\MySQLdb\constants
  copying MySQLdb\constants\ER.py -> build\lib.win-amd64-3.5\MySQLdb\constants
  copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-3.5\MySQLdb\constants
  copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-3.5\MySQLdb\constants
  running build_ext
  building 'MySQLdb._mysql' extension
  error: [WinError 2] 系统找不到指定的文件。
  ----------------------------------------
  ERROR: Failed building wheel for mysqlclient

原因:
MySQLdb不再支持python3
解决方法:
需要到pythonlibs网站上下载.whl文件进行安装
mysqlclient
需要以自己的系统和python版本对应
Python系列 | Python3.5安装MysqlClient教程_第1张图片
下载后,CD到对应的文件目录执行

pip install mysqlclient-1.4.6-cp35-cp35m-win_amd64.whl

打开pycharm -> setting查看

Python系列 | Python3.5安装MysqlClient教程_第2张图片
安装成功!

你可能感兴趣的:(Python,mysql,linux,sql)