pycharm下安装flask-mysqldb出错

今天继续学习flask。以前都是在Jupyter notebook上搞,但是好像只能编辑原始代码,不能进一步开发。要么就是在ubuntu上面直接拷贝粘贴,但是好像还是不是很专业。所以希望用一下pycharm进行开发。

遇到下面的问题:

pip install flask-mysqldb

error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/

网上解决方案如下:
安装flaskmysqldb报错.表明缺少相关*

error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
解决办法:

1 下载相关wheel

网站:https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python

下载软件:mysqlclient-1.3.13-cp36-cp36m-win_amd64.whl (因为我的是64位系统,所以安装64位)

安装这个whl:将其放在你的python环境里面.

pip install D:\ProgramDefineApp\Anaconda3\envs\flask_venv\mysqlclient-1.3.13-cp36-cp36m-win_amd64.whl

2 就可以安装flask-mysqldb

pip install flask-mysqldb

 

本人操作如下:

在Anaconda环境
(base) E:\zcm下载>python --version
Python 3.7.4

https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python
下载合适的版本mysqlclient-1.4.6-cp37-cp37m-win_amd64.whl
(base) E:\download>pip install mysqlclient-1.4.6-cp37-cp37m-win_amd64.whl
Processing e:\download\mysqlclient-1.4.6-cp37-cp37m-win_amd64.whl
Installing collected packages: mysqlclient
Successfully installed mysqlclient-1.4.6


但实际上开发用的是pycharm环境,还需要重新下载
下载mysqlclient-1.4.6-cp38-cp38-win_amd64.whl
pycharm下面
(venv) C:\Users\Administrator\PycharmProjects>pip install mysqlclient-1.4.6-cp38-cp38-win_amd64.whl
mysqlclient-1.4.6-cp38-cp38-win_amd64.whl is not a supported wheel on this platform.

首先确定python的具体版本
(venv) C:\Users\Administrator\PycharmProjects>python
Python 3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:37:50) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pip._internal
>>> print(pip._internal.pep425tags.get_supported())
[(‘cp38‘, ‘cp38m‘, ‘win_amd64‘), (‘cp38‘, ‘none‘, ‘win_amd64‘), (‘py3‘, ‘none‘, ‘win_amd64‘), (‘cp38‘, ‘none‘, ‘any‘), (‘cp3‘, ‘none‘, ‘any‘), (‘py38‘, ‘none‘, ‘any‘), (‘py3‘, ‘none‘, ‘any‘
), (‘py37‘, ‘none‘, ‘any‘), (‘py36‘, ‘none‘, ‘any‘), (‘py35‘, ‘none‘, ‘any‘), (‘py34‘, ‘none‘, ‘any‘), (‘py33‘, ‘none‘, ‘any‘), (‘py32‘, ‘none‘, ‘any‘), (‘py31‘, ‘none‘, ‘any‘), (‘py30‘, ‘n
one‘, ‘any‘)]
修改文件名

mysqlclient-1.4.6-cp38-cp38m-win_amd64.whl

重新安装
(venv) C:\Users\Administrator\PycharmProjects>pip install mysqlclient-1.4.6-cp38-cp38m-win_amd64.whl
Processing c:\users\administrator\pycharmprojects\mysqlclient-1.4.6-cp38-cp38m-win_amd64.whl
Installing collected packages: mysqlclient
Successfully installed mysqlclient-1.4.6

完美解决mysqlclient安装
pip install flask-mysqldb随之安装成功

 

pycharm下安装flask-mysqldb出错

上一篇:adb常用命令


下一篇:Mysql多条数据以一条展示和判断某字符是否在某字段