pip安装mysqlclient错误

e0uiprwp  于 2021-06-24  发布在  Mysql
关注(0)|答案(10)|浏览(479)

当我使用命令时,我正在尝试用pip导入mysqlclient library for python pip install mysqlclient 它返回一个错误:

Collecting mysqlclient
Using cached     https://files.pythonhosted.org/packages/ec/fd/83329b9d3e14f7344d1cb31f128e6dbba70c5975c9e57896815dbb1988ad/mysqlclient-1.3.13.tar.gz
Installing collected packages: mysqlclient
Running setup.py install for mysqlclient ... error
Complete output from command c:\users\astrina\appdata\local\programs\python\python36\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\astrina\\AppData\\Local\\Temp\\pip-install-40l_x_f4\\mysqlclient\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\astrina\AppData\Local\Temp\pip-record-va173t5v\install-record.txt --single-version-externally-managed --compile:
c:\users\astrina\appdata\local\programs\python\python36\lib\distutils\dist.py:261: UserWarning: Unknown distribution option: 'long_description_content_type'
  warnings.warn(msg)
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.6
copying _mysql_exceptions.py -> build\lib.win-amd64-3.6
creating build\lib.win-amd64-3.6\MySQLdb
copying MySQLdb\__init__.py -> build\lib.win-amd64-3.6\MySQLdb
copying MySQLdb\compat.py -> build\lib.win-amd64-3.6\MySQLdb
copying MySQLdb\connections.py -> build\lib.win-amd64-3.6\MySQLdb
copying MySQLdb\converters.py -> build\lib.win-amd64-3.6\MySQLdb
copying MySQLdb\cursors.py -> build\lib.win-amd64-3.6\MySQLdb
copying MySQLdb\release.py -> build\lib.win-amd64-3.6\MySQLdb
copying MySQLdb\times.py -> build\lib.win-amd64-3.6\MySQLdb
creating build\lib.win-amd64-3.6\MySQLdb\constants
copying MySQLdb\constants\__init__.py -> build\lib.win-amd64-3.6\MySQLdb\constants
copying MySQLdb\constants\CLIENT.py -> build\lib.win-amd64-3.6\MySQLdb\constants
copying MySQLdb\constants\CR.py -> build\lib.win-amd64-3.6\MySQLdb\constants
copying MySQLdb\constants\ER.py -> build\lib.win-amd64-3.6\MySQLdb\constants
copying MySQLdb\constants\FIELD_TYPE.py -> build\lib.win-amd64-3.6\MySQLdb\constants
copying MySQLdb\constants\FLAG.py -> build\lib.win-amd64-3.6\MySQLdb\constants
copying MySQLdb\constants\REFRESH.py -> build\lib.win-amd64-3.6\MySQLdb\constants
running build_ext
building '_mysql' extension
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

----------------------------------------
Command "c:\users\astrina\appdata\local\programs\python\python36\python.exe -u -c "import setuptools, 
tokenize;__file__='C:\\Users\\astrina\\AppData\\Local\\Temp\\pip-install- 
40l_x_f4\\mysqlclient\\setup.py';f=getattr(tokenize, 'open', open) 
(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, 
__file__, 'exec'))" install --record C:\Users\astrina\AppData\Local\Temp\pip- 
record-va173t5v\install-record.txt --single-version-externally-managed -- 
compile" failed with error code 1 in C:\Users\astrina\AppData\Local\Temp\pip- 
install-40l_x_f4\mysqlclient\

我已经安装了microsoft build tools 2015,但问题仍然存在

xj3cbfub

xj3cbfub1#

您可能需要安装python3和mysql开发头和库,例如:对于ubuntu或debian

sudo apt-get install python3-dev default-libmysqlclient-dev build-essential

红帽/centos

sudo yum install python3-devel mysql-devel

那就试试吧

pip install mysqlclient
mepcadol

mepcadol2#

试试皮普 install --only-binary :all: mysqlclient 为我工作

vmpqdwk3

vmpqdwk33#

可以显式设置ssl库路径。

LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysqlclient
f3temu5u

f3temu5u4#

安装
build-essential sudo apt-get install build-essential 安装
mysqlclient pip install mysqlclient

nbewdwxp

nbewdwxp5#

我也有同样的问题,我用一种非常愚蠢的方式解决了。我刚刚卸载了python并通过微软商店安装了它。

svmlkihl

svmlkihl6#

最好安装64位python。那么 pip install mysqlclient 否则您可以按照以下步骤使用python扩展包进行安装

mdfafbf1

mdfafbf17#

请尝试从wheel下载并安装。记下python版本并下载正确的版本。
https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysqlclient

w7t8yxp5

w7t8yxp58#

首先安装python3.6.5,然后运行

pip install mysqlclient==1.3.12
kmpatx3s

kmpatx3s9#

对我来说,这是一个旧的安装工具和丢失的软件包的混合物

pip install --upgrade setuptools

apt install gcc libssl-dev
cidc1ykv

cidc1ykv10#

先试试这个命令
(适当保留空间,即pip space install space——仅二进制空间:all:space mysqlclient) pip install --only-binary :all: mysqlclient 如果仍然有错误,那么试试这个。。。转到这个网站python扩展包,按ctrl+f并搜索mysqlclient。你会发现这样的文件名。。mysqlclient‑1.4.5‑cp38‑cp38‑win\u amd64.whl
仔细选择——根据python版本,有一个选择的步骤。
cp38表示python3.8版本,cp37表示python3.6版本,因此首先检查python版本是否为3.8、3.7、3.6、3.5、3.4,然后相应地下载。
amd64---在检查python版本时,还要检查python是64位还是32位。然后相应地选择。如果python是32位的,那么选择amd32。
否则你将面临问题。然后下载文件并使用pip命令手动安装。给出了一些步骤below:-
下载后,打开命令提示符并转到下载文件可用的目录(或更好地剪切该文件并粘贴到桌面),然后键入: NOTE :- PLEASE TYPE AFTER DOWNLOAD THE FILE... This is for python 3.8 and 64-bit $ pip install mysqlclient‑1.4.5‑cp38‑cp38‑win_amd64.whl For python 3.7 and 32-bit $ pip install mysqlclient‑1.4.5‑cp37‑cp37m‑win32.whl

相关问题