找回密码
 注册
查看: 33|回复: 2

pip install mysqlclient错误提示

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2024-7-27 21:00:05 | 显示全部楼层 |阅读模式
pip install mysqlclient$ i+ q+ l* D* B" B1 ]% c: U6 H
Collecting mysqlclient
2 c3 L2 z1 w9 ?" S5 X+ w  Using cached mysqlclient-2.2.4.tar.gz (90 kB)+ t% I8 Z8 |4 k/ A
  Installing build dependencies ... done$ y7 `8 C' W# O
  Getting requirements to build wheel ... done
1 j: J$ i  d. g5 t  ^, o  Preparing metadata (pyproject.toml) ... done
3 l/ n+ k$ o5 U) ^; mBuilding wheels for collected packages: mysqlclient. P  ?9 @& E  ~( ?1 o. V
  Building wheel for mysqlclient (pyproject.toml) ... error
$ J+ u, x% `" q+ m9 ^! l& T% N# `  error: subprocess-exited-with-error3 b. [* m+ H7 S  Q1 ?5 i- T
) [  T6 Q8 J  ~/ ~% V0 {/ t
  × Building wheel for mysqlclient (pyproject.toml) did not run successfully.7 L2 u5 F# f1 I- q' i
  │ exit code: 1! _# A/ J8 A" G  J+ p$ W
  ╰─> [63 lines of output]$ v6 G- x3 a% u! S% d  d& `
      # Options for building extension module:  K$ `! O3 e  M8 l) g+ q7 q
        extra_compile_args: ['-I/usr/include/mysql', '-std=c99']8 Z! N6 H) D4 Z, X9 b% o5 s% Y4 g* P
        extra_link_args: ['-L/usr/lib/x86_64-linux-gnu']4 \* i% U" [, s1 }" D
        define_macros: [('version_info', (2, 2, 4, 'final', 0)), ('__version__', '2.2.4')]: y! D) z9 H% _0 E) k' ?
      running bdist_wheel# z9 N9 L* G! ?% `3 z+ ]
      running build
$ H! V; h0 p2 Z- }0 {      running build_py4 T* p; ^2 }2 D) b
      creating build. E' W" V9 E! V6 D& Y( B" P/ l; f
      creating build/lib.linux-x86_64-cpython-312" E/ M5 f0 s) j, p, c- b! E# T  x
      creating build/lib.linux-x86_64-cpython-312/MySQLdb  f" A' R0 v- l! Y' k$ R) r' V
      copying src/MySQLdb/__init__.py -> build/lib.linux-x86_64-cpython-312/MySQLdb
9 ~) v+ m# X. F2 k& L5 i6 v+ F      copying src/MySQLdb/_exceptions.py -> build/lib.linux-x86_64-cpython-312/MySQLdb
. _8 L4 _% O3 l      copying src/MySQLdb/connections.py -> build/lib.linux-x86_64-cpython-312/MySQLdb
: V! b6 V7 d1 `9 A; ^- T5 T# m: ~      copying src/MySQLdb/converters.py -> build/lib.linux-x86_64-cpython-312/MySQLdb+ Q( I( G5 f. X$ r' t. \0 n% @
      copying src/MySQLdb/cursors.py -> build/lib.linux-x86_64-cpython-312/MySQLdb
  Q( Q# y3 ^9 ^: `+ |. [- V      copying src/MySQLdb/release.py -> build/lib.linux-x86_64-cpython-312/MySQLdb" }9 }5 C# |2 C
      copying src/MySQLdb/times.py -> build/lib.linux-x86_64-cpython-312/MySQLdb+ T0 L- ^5 s) I. Y# z- N
      creating build/lib.linux-x86_64-cpython-312/MySQLdb/constants
- h4 R# V. K2 h: V      copying src/MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants
" v, l) R: ]( \! i9 j      copying src/MySQLdb/constants/CR.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants
  y  N$ [2 k/ U; l7 n0 {6 C8 \      copying src/MySQLdb/constants/ER.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants, v  }0 U# \* O$ d6 w2 `
      copying src/MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants
- ?8 a. Y  |& i7 L' Y1 j- j- I  v      copying src/MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants& }# _2 N+ i3 t% Z( p4 {. D$ H2 Z
      copying src/MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants0 h' r/ x. }# e4 ?' Z
      running egg_info
3 b& N$ r: j; ?( e! L4 u      writing src/mysqlclient.egg-info/PKG-INFO
, w% r# k& p) Y+ [- P6 U# I3 L' A6 I      writing dependency_links to src/mysqlclient.egg-info/dependency_links.txt
7 ^! t8 z+ t/ Q$ Q; }; p: ?      writing top-level names to src/mysqlclient.egg-info/top_level.txt
: Z8 ^7 {1 O  n1 n9 Z% p/ f7 Y      reading manifest file 'src/mysqlclient.egg-info/SOURCES.txt'
4 q5 W% E1 i! Y$ Z' L+ _% D      reading manifest template 'MANIFEST.in'
/ }+ f. ]/ v, ~2 f/ C4 ]      adding license file 'LICENSE'* E8 Y& U1 h6 U: I" s" n
      writing manifest file 'src/mysqlclient.egg-info/SOURCES.txt'
; l% }8 u" w7 h      copying src/MySQLdb/_mysql.c -> build/lib.linux-x86_64-cpython-312/MySQLdb
6 l& I* j: M- X3 c, Y! O6 e" n      running build_ext
/ q! y! d5 K& z4 W! c+ S      building 'MySQLdb._mysql' extension
, T- T4 j- h2 V. l6 z      creating build/temp.linux-x86_64-cpython-312
( a0 D4 p8 |8 e5 m& d7 ~      creating build/temp.linux-x86_64-cpython-312/src) x( F: y7 k( n% }/ f  w) J" G
      creating build/temp.linux-x86_64-cpython-312/src/MySQLdb
' `( i0 _6 ^3 g% n- J      gcc -std=gnu11 -pthread -fno-strict-overflow -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC "-Dversion_info=(2, 2, 4, 'final', 0)" -D__version__=2.2.4 -I/usr/local/python312/include/python3.12 -c src/MySQLdb/_mysql.c -o build/temp.linux-x86_64-cpython-312/src/MySQLdb/_mysql.o -I/usr/include/mysql -std=c99! K+ u! v, U% A4 @0 g, V
      src/MySQLdb/_mysql.c: 在函数‘_mysql_ConnectionObject_Initialize’中:2 ]1 j1 J4 R8 C- g9 b
      src/MySQLdb/_mysql.c:539:44: 错误:‘MYSQL_OPT_SSL_KEY’未声明(在此函数内第一次使用)
" I3 {9 O$ B' C" c" C; t               mysql_options(&(self->connection), MYSQL_OPT_SSL_KEY, key);4 q2 h: T8 o% \8 v
                                                  ^
1 J( U* r# R8 O8 z      src/MySQLdb/_mysql.c:539:44: 附注:每个未声明的标识符在其出现的函数内只报告一次! A! |% U$ P0 M: W$ m
      src/MySQLdb/_mysql.c:540:44: 错误:‘MYSQL_OPT_SSL_CERT’未声明(在此函数内第一次使用)
( o( [3 F% f- c& i* @+ y( W3 i# f               mysql_options(&(self->connection), MYSQL_OPT_SSL_CERT, cert);
2 U: H* i$ E* B1 M% L$ H5 Q                                                  ^+ p: e1 ]& [/ ^( O& P' _
      src/MySQLdb/_mysql.c:541:44: 错误:‘MYSQL_OPT_SSL_CA’未声明(在此函数内第一次使用)) L% _1 B2 I9 Y( N! M
               mysql_options(&(self->connection), MYSQL_OPT_SSL_CA, ca);
4 ^% H2 s# L0 H; p                                                  ^, v; V. s# B8 K  x& Z
      src/MySQLdb/_mysql.c:542:44: 错误:‘MYSQL_OPT_SSL_CAPATH’未声明(在此函数内第一次使用)
4 N, S: Y" F! y) j7 }* F               mysql_options(&(self->connection), MYSQL_OPT_SSL_CAPATH, capath);
7 [/ w/ y# k: v$ I; k/ t( l                                                  ^  k$ y  E- `1 g- X
      src/MySQLdb/_mysql.c:543:44: 错误:‘MYSQL_OPT_SSL_CIPHER’未声明(在此函数内第一次使用)7 Z% k# u: @* ]7 |
               mysql_options(&(self->connection), MYSQL_OPT_SSL_CIPHER, cipher);
9 K- j& V/ `) b" N3 G! F                                                  ^
' M' _7 F% O$ t& w( H: P3 }      src/MySQLdb/_mysql.c:556:13: 警告:隐式声明函数‘mysql_optionsv’ [-Wimplicit-function-declaration]
- m) \; E; |( ^4 _0 g                   mysql_optionsv(&(self->connection), MYSQL_OPT_SSL_ENFORCE, (void *)&enforce_tls);
4 X+ R9 x* O  z  l+ H$ ~                   ^" K7 y( e" ?* `7 x* `
      src/MySQLdb/_mysql.c:556:49: 错误:‘MYSQL_OPT_SSL_ENFORCE’未声明(在此函数内第一次使用)1 r. l1 n' K: B; m& E/ y
                   mysql_optionsv(&(self->connection), MYSQL_OPT_SSL_ENFORCE, (void *)&enforce_tls);' y. w6 y6 {0 \( |
                                                       ^/ A2 t# Z; n: R: S5 k
      error: command '/usr/bin/gcc' failed with exit code 1) H5 m; W0 z6 m- E
      [end of output]: c) i0 s- j0 R. G& g
  j& K" O6 y6 a; o0 v$ W- A1 `
  note: This error originates from a subprocess, and is likely not a problem with pip.
* y1 M6 X2 D6 {( J- g  ERROR: Failed building wheel for mysqlclient
5 i) ^: f7 A6 m- u' s" y' eFailed to build mysqlclient
& F6 F, B( ]' f; O* _2 zERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (mysqlclient)
# x  V0 f' e9 ?
+ V  }9 }$ y. P$ g; Z7 G/ W; ?% c' g/ t" x0 a* B6 N: S4 {' z2 R
0 s6 A0 T& ~# J0 n
7 a' \/ @' p# H; ]3 L) z/ S
解决方法:
9 y7 H1 n- C% R- z, S! X0 t# W5 w/ z6 `: b7 a
降低mysqlclient 版本,替换mysqlclient-2.0.2 为1:. x$ u/ t* \# @% J; A
# L% e9 B6 r! t" h, `
apache-airflow-providers-mysql==5.4.0: I& k2 R$ @/ Z& R- s
mysqlclient==2.1.0  \3 l/ k  Y# N! v4 ]
. A& f9 B1 X$ F8 o9 V
; z( q, d, S. c. a8 ?. b
4 ~; Q6 ]. t; _* I3 o4 H! N8 S  V

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2024-7-27 21:00:06 | 显示全部楼层
[root@python-flask ~]# pip install mysqlclient/ O- r. _. [0 o; y7 o% i
Collecting mysqlclient
0 m& z" w& k% V6 f  Using cached mysqlclient-2.2.4.tar.gz (90 kB)! O$ @7 v, a' e7 E$ V
  Installing build dependencies ... done( W' I$ r/ Z% h" W) X
  Getting requirements to build wheel ... error
9 t" a# @4 @' m. j, A1 Q  error: subprocess-exited-with-error
- o5 N7 u$ l! k6 \9 h, g: g  
1 i% M% q1 |& Y  × Getting requirements to build wheel did not run successfully.5 }: V7 V/ I* e. v) q
  │ exit code: 1
$ v4 W7 R) x% c& P* Z! k  ╰─> [27 lines of output]* b8 h5 A% U* k. u( X. X% e4 Q* Z
      Trying pkg-config --exists mysqlclient/ E+ T0 Z% a; V/ i3 {
      Command 'pkg-config --exists mysqlclient' returned non-zero exit status 1./ O% b( r! C+ V* m/ ~
      Trying pkg-config --exists mariadb2 N( g  _7 G! T* i2 X$ M4 F
      Command 'pkg-config --exists mariadb' returned non-zero exit status 1.6 q% D9 U( c- O& r
      Trying pkg-config --exists libmariadb
8 J9 h8 u, `7 b  G0 Y      Command 'pkg-config --exists libmariadb' returned non-zero exit status 1." G* z% t( D7 B+ [& r  {1 p
      Traceback (most recent call last):+ C5 F$ M- T3 f, G3 k* `; c# v  o
        File "/usr/local/python312/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
. D* ]4 F) A" e9 N4 g          main()2 D. v' T6 e/ S, _; C/ Y
        File "/usr/local/python312/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
2 s& [( [5 s& w+ K          json_out['return_val'] = hook(**hook_input['kwargs'])
5 J6 C+ o5 n5 P                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^' Q, [; s- l3 K4 K- F# g
        File "/usr/local/python312/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel) P6 Z# ]! U# a9 ~. F* l* T8 D' u4 f
          return hook(config_settings), W5 y3 C0 @9 Z4 l# |. u
                 ^^^^^^^^^^^^^^^^^^^^^% a) J( ?" ^. Q8 v6 p1 u- R
        File "/tmp/pip-build-env-w2b8dsud/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 327, in get_requires_for_build_wheel1 M/ Q  V. M5 {1 v
          return self._get_build_requires(config_settings, requirements=[])
7 `$ D9 |" b& r  G: }) ]$ `                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: b; F! p8 v1 r( P9 a/ S1 O7 s        File "/tmp/pip-build-env-w2b8dsud/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 297, in _get_build_requires! i% P: E. _  t, L* H9 G5 Y8 \
          self.run_setup()  n9 q6 ]- _( A* |
        File "/tmp/pip-build-env-w2b8dsud/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 313, in run_setup
: ^; L3 S6 [: O' h+ K          exec(code, locals())1 W, m  Y, P2 V) C# `
        File "<string>", line 155, in <module>
, [  i1 w3 Y) g        File "<string>", line 49, in get_config_posix  L( H: {0 B. S0 {! z1 |- ~% r
        File "<string>", line 28, in find_package_name$ o* p/ I3 u; F3 |
      Exception: Can not find valid pkg-config name.
+ z& e) S- M4 `! [: @6 o# G' O. b1 Y      Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually0 \( U, {& q# `$ s5 a+ p' _
      [end of output]
3 W/ w- I4 U+ W3 Z2 N  & M4 i7 B6 e! N) @
  note: This error originates from a subprocess, and is likely not a problem with pip.
( X' s& E) T. d) ]error: subprocess-exited-with-error
2 M$ v9 O. X5 s) e& y, ]
/ |8 L7 B& z7 ~× Getting requirements to build wheel did not run successfully.
! z  q- U, q! q  I& s6 k│ exit code: 1
, j, h, C! T! |: ?! z; _╰─> See above for output./ ~9 v# e3 W# S( E& k1 f6 K7 T

$ w# x% h! v. ]: x" D  _2 {4 B3 Mnote: This error originates from a subprocess, and is likely not a problem with pip.
8 D- T+ G- z4 \9 D; e- C* ?[root@python-flask ~]# pip install mysqlclient==2.1.0, s2 f9 F2 `" {6 F# Q# i& A# W
Collecting mysqlclient==2.1.0* F# q- C& ~( ~0 H3 {7 ]
  Downloading mysqlclient-2.1.0.tar.gz (87 kB)
: s% R* p  U; B5 r     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 87.6/87.6 kB 635.5 kB/s eta 0:00:00
: x  o* }) K, ~) n) o1 l# |  G) ^/ \  Installing build dependencies ... done
* [- v# N# c( ^' `1 F' S4 |  Getting requirements to build wheel ... done
; w4 f1 J% L% ?# B6 ^* D. \  Preparing metadata (pyproject.toml) ... done
+ R  I6 S$ I; W- l1 nBuilding wheels for collected packages: mysqlclient; ~$ r8 ]; S0 f! v/ T8 P* C; h9 f
  Building wheel for mysqlclient (pyproject.toml) ... done
7 `: ?- L$ A! w( x0 M  Created wheel for mysqlclient: filename=mysqlclient-2.1.0-cp312-cp312-linux_x86_64.whl size=102434 sha256=9195914c669fe1b57f256214d711095c10e05799fdf3b2033541f88830a69b6d# w/ l7 t% _" ?# H- W' B$ I
  Stored in directory: /root/.cache/pip/wheels/b1/b6/8d/eb165ad207cde6784a606ec0a5bdd7a5b5c9241bad361d1623
" L  M+ i5 l1 J, }Successfully built mysqlclient
/ h& i( F8 L% m2 ~/ v  t: ]& G9 jInstalling collected packages: mysqlclient
, V7 X0 }  s. y7 g' r: C9 kSuccessfully installed mysqlclient-2.1.0
! |) n2 Q- f& t& i4 [) V+ x" KWARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager, possibly rendering your system unusable.It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv. Use the --root-user-action option if you know what you are doing and want to suppress this warning.+ K/ `* l/ y, e* f, O9 B& B

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2024-7-30 02:02:53 | 显示全部楼层
安装失败还有一个原因可能是因为环境不干净导致。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 00:43 , Processed in 0.016208 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表