易陆发现互联网技术论坛

 找回密码
 开始注册
查看: 28|回复: 2
收起左侧

pip install mysqlclient错误提示

[复制链接]
发表于 2024-7-27 21:00:05 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?开始注册

x
pip install mysqlclient' B/ S& r) X% Z! J
Collecting mysqlclient: }& Y0 C' W/ E" \
  Using cached mysqlclient-2.2.4.tar.gz (90 kB)
$ |( I! M" A9 O1 U4 j  Installing build dependencies ... done
% S1 y' q' u6 i8 ?; M+ P  Getting requirements to build wheel ... done
/ z' n! q$ @/ t4 ~  Preparing metadata (pyproject.toml) ... done
! k3 n) J  W3 V6 ]8 l5 OBuilding wheels for collected packages: mysqlclient4 X5 @0 J/ ~: I2 x. D! x8 s' j
  Building wheel for mysqlclient (pyproject.toml) ... error
2 W) Y+ }( g+ w. V4 _9 K/ T5 ~  error: subprocess-exited-with-error$ g) U# A5 v7 \; K% d! c1 Y
9 ]& E  r' Y3 |
  × Building wheel for mysqlclient (pyproject.toml) did not run successfully." p% J/ }* L/ \& @3 B, h, g( E
  │ exit code: 1
- D) P' x6 j: n2 H9 h2 T6 s; G  ╰─> [63 lines of output]0 j3 u$ }) e' O; s1 V
      # Options for building extension module:
# x6 w" Z1 z! k& ]  i0 |        extra_compile_args: ['-I/usr/include/mysql', '-std=c99']
* S! `* l7 D7 [( k/ W: D        extra_link_args: ['-L/usr/lib/x86_64-linux-gnu']; C/ c/ \1 z7 r
        define_macros: [('version_info', (2, 2, 4, 'final', 0)), ('__version__', '2.2.4')]5 E; @$ g; L8 V/ H( x; s* }/ j
      running bdist_wheel5 t1 U' z$ d/ n" I$ b9 e
      running build
7 U( A) N8 p6 G9 s' ~3 _      running build_py
" d. @# M( x0 p      creating build+ y3 a! E4 E: P3 H, P0 S  x
      creating build/lib.linux-x86_64-cpython-3129 F  f# }0 {  R
      creating build/lib.linux-x86_64-cpython-312/MySQLdb
3 X8 r/ R; F4 V) j8 D& X      copying src/MySQLdb/__init__.py -> build/lib.linux-x86_64-cpython-312/MySQLdb
' R. |$ m( U4 ?+ ^7 @      copying src/MySQLdb/_exceptions.py -> build/lib.linux-x86_64-cpython-312/MySQLdb
2 x) _1 T. v- k6 S      copying src/MySQLdb/connections.py -> build/lib.linux-x86_64-cpython-312/MySQLdb& R6 K  W3 S, M) S2 L8 E' h7 t. i1 [
      copying src/MySQLdb/converters.py -> build/lib.linux-x86_64-cpython-312/MySQLdb) S& `- E) t6 T' }4 O
      copying src/MySQLdb/cursors.py -> build/lib.linux-x86_64-cpython-312/MySQLdb
2 L8 ?' [( @1 p0 I9 W3 n      copying src/MySQLdb/release.py -> build/lib.linux-x86_64-cpython-312/MySQLdb
. [* K$ @( ]5 j, ]5 y      copying src/MySQLdb/times.py -> build/lib.linux-x86_64-cpython-312/MySQLdb
, {, q+ p' z0 A1 z/ g      creating build/lib.linux-x86_64-cpython-312/MySQLdb/constants5 a$ C6 i/ u' l2 Z
      copying src/MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants
" {0 M, \8 k6 ]! U$ p1 C6 d      copying src/MySQLdb/constants/CR.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants8 r! h& R" z5 w1 B) w
      copying src/MySQLdb/constants/ER.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants
0 b. N* Q3 h2 a- S# Y' ^      copying src/MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants4 r& x# M9 J5 [, V7 l
      copying src/MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants
& `+ a, Q/ z6 e! ~) w      copying src/MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants' Z+ y& S8 [! J4 g
      running egg_info, N. r7 F+ G, H
      writing src/mysqlclient.egg-info/PKG-INFO
( \5 a. A2 a' ^, }      writing dependency_links to src/mysqlclient.egg-info/dependency_links.txt/ P4 f' G8 E& d0 ?% u& X; N1 t
      writing top-level names to src/mysqlclient.egg-info/top_level.txt
; d5 O6 q/ M4 I      reading manifest file 'src/mysqlclient.egg-info/SOURCES.txt'- C- B3 R8 y- r  }" y$ `4 T# V$ i
      reading manifest template 'MANIFEST.in'4 e8 s0 M, L- |
      adding license file 'LICENSE'+ {$ z" ~2 @( d: M5 S. J) w0 I
      writing manifest file 'src/mysqlclient.egg-info/SOURCES.txt'
2 X! z: ]& H" f6 m0 y" G: \      copying src/MySQLdb/_mysql.c -> build/lib.linux-x86_64-cpython-312/MySQLdb
3 _" g4 m! \5 f      running build_ext$ r! S8 a/ ?+ q" D$ O+ h
      building 'MySQLdb._mysql' extension' ?3 Z6 i( h, l* p" |& A# ^
      creating build/temp.linux-x86_64-cpython-312
7 Z) n2 o1 X/ s" B" M1 Z      creating build/temp.linux-x86_64-cpython-312/src
; G" y$ f7 S: U0 m5 f      creating build/temp.linux-x86_64-cpython-312/src/MySQLdb: ]" B; B6 q$ {: D4 b, K* U
      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/ g0 q8 m& ~" G+ X& f+ L$ s: N
      src/MySQLdb/_mysql.c: 在函数‘_mysql_ConnectionObject_Initialize’中:
3 I0 r: a0 s2 R4 i  d3 k2 M0 ?' u8 V      src/MySQLdb/_mysql.c:539:44: 错误:‘MYSQL_OPT_SSL_KEY’未声明(在此函数内第一次使用)/ n# M" c3 r: E+ r
               mysql_options(&(self->connection), MYSQL_OPT_SSL_KEY, key);! i) o" A# Y# A
                                                  ^
, z3 Y5 h; l! d0 P0 ]      src/MySQLdb/_mysql.c:539:44: 附注:每个未声明的标识符在其出现的函数内只报告一次
2 p9 h; w' c9 D$ X      src/MySQLdb/_mysql.c:540:44: 错误:‘MYSQL_OPT_SSL_CERT’未声明(在此函数内第一次使用)9 T% T7 g& C/ Q0 S/ F- H" ]& G
               mysql_options(&(self->connection), MYSQL_OPT_SSL_CERT, cert);8 b  S" k9 f% I; ^1 ?! E5 J
                                                  ^
% r; L% {" h5 ~: t' q      src/MySQLdb/_mysql.c:541:44: 错误:‘MYSQL_OPT_SSL_CA’未声明(在此函数内第一次使用)* Q" q: f5 J$ b% a
               mysql_options(&(self->connection), MYSQL_OPT_SSL_CA, ca);
" P+ R9 Y7 m" `# f- \. ^0 y, c+ ]                                                  ^6 ^0 w, l9 r( J, x
      src/MySQLdb/_mysql.c:542:44: 错误:‘MYSQL_OPT_SSL_CAPATH’未声明(在此函数内第一次使用)* P7 X" O: F8 N6 B) l
               mysql_options(&(self->connection), MYSQL_OPT_SSL_CAPATH, capath);
. |5 K) J& [" b0 \  w2 j$ p) M& G6 Q                                                  ^
# s3 x: y+ E6 b/ _$ T      src/MySQLdb/_mysql.c:543:44: 错误:‘MYSQL_OPT_SSL_CIPHER’未声明(在此函数内第一次使用)1 y, k; F' F7 t- E
               mysql_options(&(self->connection), MYSQL_OPT_SSL_CIPHER, cipher);
! c0 @8 A* e! v                                                  ^3 ]# _7 O8 S8 r! @
      src/MySQLdb/_mysql.c:556:13: 警告:隐式声明函数‘mysql_optionsv’ [-Wimplicit-function-declaration]
. ]2 ?) r6 H  ], X/ d3 F0 G                   mysql_optionsv(&(self->connection), MYSQL_OPT_SSL_ENFORCE, (void *)&enforce_tls);; y$ n6 j$ O. C5 l# }2 C
                   ^
' N+ E8 b* }% `; n7 _* o      src/MySQLdb/_mysql.c:556:49: 错误:‘MYSQL_OPT_SSL_ENFORCE’未声明(在此函数内第一次使用)
, j4 H% N3 R6 B& T. g# }                   mysql_optionsv(&(self->connection), MYSQL_OPT_SSL_ENFORCE, (void *)&enforce_tls);7 F8 e5 W, P- R( j  a
                                                       ^5 k. V2 l, M* P7 q) Z
      error: command '/usr/bin/gcc' failed with exit code 1
* l- E. j9 ~$ g0 @; q" K      [end of output]- t; I( t6 R! A
  N4 ~: T  S& o* ?, f
  note: This error originates from a subprocess, and is likely not a problem with pip.
) w5 ^. x* p4 f8 Q  e  ERROR: Failed building wheel for mysqlclient
+ j/ ^0 e9 S! @$ jFailed to build mysqlclient
: U+ S2 M/ i* {& bERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (mysqlclient)3 l2 k5 M8 `3 y+ D! y6 D
7 i) w5 N: D, {) c9 l& _
/ @" D/ u5 L6 J' p2 l( G
4 }/ ?, }1 q2 `* O$ A
5 H, T! G9 x& W1 j; }! F$ o7 b  n
解决方法:1 m7 j6 W% P; U7 h

! ]7 ?1 S) r: Z' g4 A& y降低mysqlclient 版本,替换mysqlclient-2.0.2 为1:" d6 Q4 i) I8 c
! o' n/ c' f$ I, v3 ?
apache-airflow-providers-mysql==5.4.0: u$ K& k+ U3 E5 {6 V% Z, ?
mysqlclient==2.1.0! `# u, B! b! l. r( b5 W0 D
9 W6 |+ ^  r0 @# ?) w. M) L- G2 _/ P

. L/ f" C% K4 B  m3 m) I
9 D0 [$ O# h; m; v
 楼主| 发表于 2024-7-27 21:00:06 | 显示全部楼层
[root@python-flask ~]# pip install mysqlclient# U; O5 Z$ U3 ^8 s' D7 p
Collecting mysqlclient
( T8 h) H' d7 d5 L2 @" _8 `  Using cached mysqlclient-2.2.4.tar.gz (90 kB). J. s. O1 R- E& t% L6 B8 v* }
  Installing build dependencies ... done
, v1 o0 t% n0 b1 M4 O  `* `5 S  Getting requirements to build wheel ... error
: L9 a; ~0 Z& n) i- ^" R  error: subprocess-exited-with-error" |, M) u( v0 {/ d, f# a
  
( X& i8 z+ k7 g* \' N" f- s( J  × Getting requirements to build wheel did not run successfully.. ?, d# x% K! n, c
  │ exit code: 1: y, x; {- ~2 j1 x# Z+ j$ U# |$ }: n
  ╰─> [27 lines of output]
8 e# x$ ?/ S, j6 s7 C+ `      Trying pkg-config --exists mysqlclient
2 L, ]! f( j1 Z6 G! z      Command 'pkg-config --exists mysqlclient' returned non-zero exit status 1.' u4 \4 c0 K  S; h) A& x
      Trying pkg-config --exists mariadb
6 ]' ~& d' C) s      Command 'pkg-config --exists mariadb' returned non-zero exit status 1.: a  W; H, f2 g+ ~
      Trying pkg-config --exists libmariadb" R4 H, U  m" w* L; c) C4 _9 ]
      Command 'pkg-config --exists libmariadb' returned non-zero exit status 1.
* Y4 Z3 p* m. t6 \5 @, q8 W! C2 P3 F      Traceback (most recent call last):
+ R9 I. D, _" z6 \& V        File "/usr/local/python312/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>4 H- ?) Z& q7 R& y
          main()8 y: ]1 k: c, a! ]9 _9 p
        File "/usr/local/python312/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main+ U1 d9 A! M4 y8 z' U' m) h
          json_out['return_val'] = hook(**hook_input['kwargs'])
* e; l, q3 c% }9 V. x9 o" i/ J                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^+ U, q0 M! }+ I% P0 X9 e; \
        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_wheel9 `- q* b+ s% X- ?# o# h! I
          return hook(config_settings)0 o, J8 H" M4 A; y4 B
                 ^^^^^^^^^^^^^^^^^^^^^
- n* s' P3 l6 A1 L. N. r        File "/tmp/pip-build-env-w2b8dsud/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 327, in get_requires_for_build_wheel: i" g4 a) a1 N, M$ `, k' \9 p
          return self._get_build_requires(config_settings, requirements=[])
' k5 A2 E) c- e# \1 ]  U                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^/ g7 |" q5 \$ y2 ~
        File "/tmp/pip-build-env-w2b8dsud/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 297, in _get_build_requires  i3 {; u1 `: y5 ]( d( T
          self.run_setup()
4 c  l' j( h+ E: D( J; F7 R" r        File "/tmp/pip-build-env-w2b8dsud/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 313, in run_setup9 W* F; m! X) d- O& R) |- B
          exec(code, locals())
1 e0 r; r# N2 z8 _; \        File "<string>", line 155, in <module>; w& N/ q1 h  a  k3 I+ i' O0 N
        File "<string>", line 49, in get_config_posix
2 m- o  q; C- b0 a3 K9 t+ {        File "<string>", line 28, in find_package_name
5 Z  z# a/ [3 N1 @) W. p  J      Exception: Can not find valid pkg-config name.
8 @% `. ~% i+ v9 H! y% {/ Q  h      Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually
4 D0 a% B1 r: Y. @0 }4 t      [end of output]$ T  j3 @2 |. T/ ]: {) w1 o
  
" |9 m2 S6 |8 c2 c6 `  note: This error originates from a subprocess, and is likely not a problem with pip.
9 ]. W6 |8 y- |% T( Y$ B0 W$ G2 Q8 _error: subprocess-exited-with-error2 V' j# J2 R; `

. x, E/ I" |) j, B× Getting requirements to build wheel did not run successfully.; z$ y* R$ G3 ~( n
│ exit code: 1" R/ C$ X7 A/ W2 ^
╰─> See above for output.# ?' {5 b0 C% r! `* C; ~

* ^; h, _& Y! {' ^( K; H5 nnote: This error originates from a subprocess, and is likely not a problem with pip.
3 b( ]& Q: y& G[root@python-flask ~]# pip install mysqlclient==2.1.0
$ `. H* S7 y2 d4 D& M" gCollecting mysqlclient==2.1.00 ?7 r' {& v* b
  Downloading mysqlclient-2.1.0.tar.gz (87 kB)0 K& k+ h; h/ X' H% \
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 87.6/87.6 kB 635.5 kB/s eta 0:00:00& k! \( A; y: @- f+ i) C
  Installing build dependencies ... done" _( B- E& @$ C1 l
  Getting requirements to build wheel ... done
1 I3 X. s: y1 q6 U  Preparing metadata (pyproject.toml) ... done( G4 `# M- _9 ?: g
Building wheels for collected packages: mysqlclient. _8 `& Y3 l/ _7 F
  Building wheel for mysqlclient (pyproject.toml) ... done# m% T! @3 _3 D# e: ]) Q& m! J
  Created wheel for mysqlclient: filename=mysqlclient-2.1.0-cp312-cp312-linux_x86_64.whl size=102434 sha256=9195914c669fe1b57f256214d711095c10e05799fdf3b2033541f88830a69b6d- [/ \( J; P' |+ [# |& j
  Stored in directory: /root/.cache/pip/wheels/b1/b6/8d/eb165ad207cde6784a606ec0a5bdd7a5b5c9241bad361d1623% ]) N" I2 L) m) ?
Successfully built mysqlclient
- C) {, g; t$ Q8 F" i5 t% FInstalling collected packages: mysqlclient
) z; d9 }: H+ t7 H* x3 D  G4 ISuccessfully installed mysqlclient-2.1.0
( Y' }; X4 O+ ^# b5 aWARNING: 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.
# c. A5 d. r2 x+ a3 I- S1 g
 楼主| 发表于 2024-7-30 02:02:53 | 显示全部楼层
安装失败还有一个原因可能是因为环境不干净导致。
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

站长推荐上一条 /4 下一条

北京云银创陇科技有限公司以云计算运维,代码开发

QQ|返回首页|Archiver|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )点击这里给我发消息

GMT+8, 2026-4-8 23:59 , Processed in 0.054501 second(s), 22 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

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