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

pip install mysqlclient错误提示

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2024-7-27 21:00:05 | 显示全部楼层 |阅读模式
pip install mysqlclient- [- M) j' a7 [* i4 x
Collecting mysqlclient
% K$ e9 p: |- ~% Q+ {. q6 g$ D8 Q  Using cached mysqlclient-2.2.4.tar.gz (90 kB)' B3 a! N7 v- j! F7 s5 z/ S5 K
  Installing build dependencies ... done3 l5 K) v( @, V& U/ r/ l# V
  Getting requirements to build wheel ... done
& X  f' \9 U8 B2 [' E0 i  Preparing metadata (pyproject.toml) ... done( X& r7 _2 l' f9 q) F' G
Building wheels for collected packages: mysqlclient
" t6 o! v6 }- |  H5 g+ U9 {  Building wheel for mysqlclient (pyproject.toml) ... error
4 }2 [6 Y8 Y" Y$ n4 _9 }  error: subprocess-exited-with-error/ n3 s3 I) J: o  y7 O/ Z: u

: q( ^3 h0 q4 p  × Building wheel for mysqlclient (pyproject.toml) did not run successfully.; `& k. q/ l( }% R0 N
  │ exit code: 1
: S  R+ p3 Y; y5 k, i  ╰─> [63 lines of output]+ g3 \/ q# W7 a2 z
      # Options for building extension module:7 \6 R  u1 R2 [% h- r' Q
        extra_compile_args: ['-I/usr/include/mysql', '-std=c99']
1 ]! }% A5 c+ \- l7 u3 e3 m) w        extra_link_args: ['-L/usr/lib/x86_64-linux-gnu']# i7 U$ m& D# }' y0 I
        define_macros: [('version_info', (2, 2, 4, 'final', 0)), ('__version__', '2.2.4')]/ Z, n0 \8 ~( `! g/ G: e
      running bdist_wheel
9 M2 w# |7 M. Q% N: Z+ t      running build
$ R( I* a: l% O/ V  k      running build_py
% s: g/ I1 G; z& r0 P      creating build
3 W8 l2 e  Q# U) U, a& ~2 g9 c      creating build/lib.linux-x86_64-cpython-312
: {- U# T8 y3 T9 J      creating build/lib.linux-x86_64-cpython-312/MySQLdb: {4 }+ x3 O( W; T2 u& l3 Z
      copying src/MySQLdb/__init__.py -> build/lib.linux-x86_64-cpython-312/MySQLdb
; R& P  s" @6 K' j' c* d      copying src/MySQLdb/_exceptions.py -> build/lib.linux-x86_64-cpython-312/MySQLdb
; A- W6 n2 e: o& Y# l- Z      copying src/MySQLdb/connections.py -> build/lib.linux-x86_64-cpython-312/MySQLdb# s0 a- f; o! R  L
      copying src/MySQLdb/converters.py -> build/lib.linux-x86_64-cpython-312/MySQLdb: m! F$ [1 v$ m* X, M* J
      copying src/MySQLdb/cursors.py -> build/lib.linux-x86_64-cpython-312/MySQLdb1 i! g$ K: E) d6 \4 E
      copying src/MySQLdb/release.py -> build/lib.linux-x86_64-cpython-312/MySQLdb
/ o/ e+ F$ I* a9 F* o% o+ c      copying src/MySQLdb/times.py -> build/lib.linux-x86_64-cpython-312/MySQLdb' U1 G* u+ h: J$ E% _
      creating build/lib.linux-x86_64-cpython-312/MySQLdb/constants, W1 f% p% q0 L& D5 r( M* D# a
      copying src/MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants5 n, o) Q; u" L! `
      copying src/MySQLdb/constants/CR.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants
+ A% m9 T) W3 p3 {      copying src/MySQLdb/constants/ER.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants
: A, Z. B! e4 H( d- X2 t      copying src/MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants
& s9 W% k6 [. D5 K      copying src/MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants
1 m( X, G' X/ F7 g% C4 b$ r      copying src/MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants0 e4 B, j8 t& A2 k" B+ _1 N
      running egg_info' ]) v  a- q. a1 L0 _
      writing src/mysqlclient.egg-info/PKG-INFO5 V0 R, V6 e& d6 v; r, s# B
      writing dependency_links to src/mysqlclient.egg-info/dependency_links.txt
: e6 [" J% B6 V2 P1 O( x, x5 d, J      writing top-level names to src/mysqlclient.egg-info/top_level.txt$ I+ {" B, M: Z6 s/ I
      reading manifest file 'src/mysqlclient.egg-info/SOURCES.txt'
4 k2 p4 A3 ^6 ?" K5 |# e      reading manifest template 'MANIFEST.in'
3 Q8 X6 ^9 W3 w8 U2 D      adding license file 'LICENSE'
  T# B$ M  U% `: A' b* c/ n      writing manifest file 'src/mysqlclient.egg-info/SOURCES.txt'
' o) g! Z8 C3 }, J3 W% i; l9 C      copying src/MySQLdb/_mysql.c -> build/lib.linux-x86_64-cpython-312/MySQLdb4 M- m: Y" _1 l; {1 S
      running build_ext
9 v+ A0 M% u! W: O. y      building 'MySQLdb._mysql' extension! R. q6 J: c/ ^& D4 s+ J" S2 R. T
      creating build/temp.linux-x86_64-cpython-312' K6 L+ {" x. }
      creating build/temp.linux-x86_64-cpython-312/src
7 `5 t- x6 P$ ~; o1 G# }) B      creating build/temp.linux-x86_64-cpython-312/src/MySQLdb, f) n+ ]) o7 D
      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
4 p3 Z. h5 g9 t, K      src/MySQLdb/_mysql.c: 在函数‘_mysql_ConnectionObject_Initialize’中:& D3 C( G# o$ O4 p: J! q" P, W5 H6 O
      src/MySQLdb/_mysql.c:539:44: 错误:‘MYSQL_OPT_SSL_KEY’未声明(在此函数内第一次使用)* H; Q6 i, g" z7 u# [. Y! Y; n- M
               mysql_options(&(self->connection), MYSQL_OPT_SSL_KEY, key);7 M+ I. Q3 W2 c; v! M4 w2 Q
                                                  ^* B- s5 V* V0 ?2 B* S
      src/MySQLdb/_mysql.c:539:44: 附注:每个未声明的标识符在其出现的函数内只报告一次, J1 s9 y; p8 V; x
      src/MySQLdb/_mysql.c:540:44: 错误:‘MYSQL_OPT_SSL_CERT’未声明(在此函数内第一次使用)5 G2 A4 L9 L: @* p
               mysql_options(&(self->connection), MYSQL_OPT_SSL_CERT, cert);9 m: M$ x9 d/ i+ \
                                                  ^, g2 i$ h! V# H8 K- K* D& y* c
      src/MySQLdb/_mysql.c:541:44: 错误:‘MYSQL_OPT_SSL_CA’未声明(在此函数内第一次使用)
$ }# G0 L4 @: p6 B2 h! {4 f6 p               mysql_options(&(self->connection), MYSQL_OPT_SSL_CA, ca);% s7 @! S0 U/ w6 A. J4 S6 X5 ]
                                                  ^
0 ^! k( `4 z4 }( z      src/MySQLdb/_mysql.c:542:44: 错误:‘MYSQL_OPT_SSL_CAPATH’未声明(在此函数内第一次使用)
3 j  R& R; f9 t) E/ n               mysql_options(&(self->connection), MYSQL_OPT_SSL_CAPATH, capath);
  z* R: S# d7 a5 B* [$ e8 |                                                  ^/ p  v; ^) a* e' H+ n# |) W) G) W
      src/MySQLdb/_mysql.c:543:44: 错误:‘MYSQL_OPT_SSL_CIPHER’未声明(在此函数内第一次使用)5 h  a1 v' J- \: X4 ?5 S. u
               mysql_options(&(self->connection), MYSQL_OPT_SSL_CIPHER, cipher);6 O8 N7 s0 [- _: `% w
                                                  ^
0 o" Y3 m% {  S2 n9 H      src/MySQLdb/_mysql.c:556:13: 警告:隐式声明函数‘mysql_optionsv’ [-Wimplicit-function-declaration]+ a& k7 V3 q; q& T+ `: U3 f" P4 n
                   mysql_optionsv(&(self->connection), MYSQL_OPT_SSL_ENFORCE, (void *)&enforce_tls);
1 D2 u/ z( v  L  W: M                   ^
6 I: u) e( k5 h4 A8 ?; o      src/MySQLdb/_mysql.c:556:49: 错误:‘MYSQL_OPT_SSL_ENFORCE’未声明(在此函数内第一次使用)
1 J% @$ L# _  i/ }" P: k                   mysql_optionsv(&(self->connection), MYSQL_OPT_SSL_ENFORCE, (void *)&enforce_tls);
/ D4 P/ ^8 S: g9 X8 q( y  y                                                       ^% {& |3 Y& {+ ?7 Q4 e; d7 y
      error: command '/usr/bin/gcc' failed with exit code 1
+ Y$ e- ~; m, p      [end of output]3 ]! M  y4 Y( w, q6 i  q6 z# T1 J

! O" @, P* @# ?. H4 J  note: This error originates from a subprocess, and is likely not a problem with pip.6 ^  x" z# j5 {& J/ o& y
  ERROR: Failed building wheel for mysqlclient; s6 U& M: ]: L" B  x
Failed to build mysqlclient
$ O: R$ \  V" y1 ?3 [- PERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (mysqlclient)' ^! h4 V1 E2 O" ]) q

" i/ j2 S; ^3 [5 D. r. X: z; c* i
3 r. ]1 y9 H& h0 d% P0 V
' @' Y# W" b0 ~# l) x: u6 |; l, t% [* m$ v; {5 n
解决方法:
* U( r$ w- o  _: `" ?$ E
* Y% d" f. ]* q. Z; |降低mysqlclient 版本,替换mysqlclient-2.0.2 为1:# f) y, B5 G5 q% r0 T- }
3 T" q+ d# W' v+ z3 x
apache-airflow-providers-mysql==5.4.0
! U6 C7 E; Z0 C( I) [mysqlclient==2.1.0
8 M) j( L: C7 n! }  s. H. g. P; b- i2 X& {1 c) `2 \) M4 H

2 R+ V5 ^8 b! I/ T# [- M
' A$ q& S1 g! c9 }

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2024-7-27 21:00:06 | 显示全部楼层
[root@python-flask ~]# pip install mysqlclient2 Y0 g. o6 P0 ~, c
Collecting mysqlclient
1 r3 L9 i( H# `  Using cached mysqlclient-2.2.4.tar.gz (90 kB)
5 Z) |7 H& _$ \9 q! h. C. m! t  |  Installing build dependencies ... done
( q0 k3 l2 w) \& n( @6 N$ C  Getting requirements to build wheel ... error4 K$ W+ ?' e# u
  error: subprocess-exited-with-error
7 g- D/ J& |. \6 O3 i. W6 l  & r/ ^$ B& j' a- C" P" j0 C
  × Getting requirements to build wheel did not run successfully.
* w* h' s, r& h# C# u  │ exit code: 19 Q1 Q6 t4 x1 e6 q. T* d- i; g: x6 \
  ╰─> [27 lines of output]7 g1 X: e9 o0 `! y( M' n* n+ H
      Trying pkg-config --exists mysqlclient
( ~: D# ?0 [5 P4 x+ a      Command 'pkg-config --exists mysqlclient' returned non-zero exit status 1.
9 N2 l9 s9 ]+ E) n3 j" ?      Trying pkg-config --exists mariadb
+ L; _% q; a3 O3 V5 L; ]3 ?' |. \      Command 'pkg-config --exists mariadb' returned non-zero exit status 1.+ ]' A! r2 G& p$ J5 E5 g
      Trying pkg-config --exists libmariadb
) T9 g9 c2 [- w. [6 o: v5 J$ W! M      Command 'pkg-config --exists libmariadb' returned non-zero exit status 1.2 |, \$ x5 `+ n5 N- g
      Traceback (most recent call last):
/ Q; b! @' ~9 S3 c        File "/usr/local/python312/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>$ Y! m2 M/ t6 ]+ F0 b( M5 U: l* x
          main()
7 P2 z- @+ D5 t5 Q; e+ j; J* Z# |: x8 F        File "/usr/local/python312/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
5 C( ^, q$ j$ ?. L          json_out['return_val'] = hook(**hook_input['kwargs'])
# E# f/ [5 r' M7 d9 [+ S- z                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
% V& H" s" B! J% O2 w        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
3 V5 }9 y, R7 }& d9 L1 a          return hook(config_settings)
8 y7 q0 Z2 c+ J                 ^^^^^^^^^^^^^^^^^^^^^
7 M3 z& A5 ]( q7 z# D2 Q7 T  _3 W        File "/tmp/pip-build-env-w2b8dsud/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 327, in get_requires_for_build_wheel2 _  Z+ p' {7 e& {! k: F) ]
          return self._get_build_requires(config_settings, requirements=[])7 J$ P- @! S6 `
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ x1 G9 c3 }, `7 Y        File "/tmp/pip-build-env-w2b8dsud/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 297, in _get_build_requires& N4 W3 Z! R  z6 C% i
          self.run_setup()3 r% }  F0 d# n; U5 K* M
        File "/tmp/pip-build-env-w2b8dsud/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 313, in run_setup% A6 s8 e8 @+ ~2 y  k
          exec(code, locals())
6 ?! l- V4 s# C        File "<string>", line 155, in <module>2 E$ \5 O7 T  ]4 n
        File "<string>", line 49, in get_config_posix; u9 s0 H) P$ I% M6 a& M$ o3 D* B
        File "<string>", line 28, in find_package_name
7 A! k8 y# x. W      Exception: Can not find valid pkg-config name./ f2 V& O% l" n; b9 o6 w" N
      Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually" M7 G. w0 t. C: T+ b( V
      [end of output]6 @- c8 a# r# l) j. L
  2 n& e2 b" `  I% \- [( B0 n0 e2 d' X" F
  note: This error originates from a subprocess, and is likely not a problem with pip.
. l9 e8 D! r3 O3 x6 L5 d- r& {error: subprocess-exited-with-error' L1 J4 X/ a) i$ [  ?- V% F

. v0 U& B5 o. q  k3 J× Getting requirements to build wheel did not run successfully.1 ]6 O1 i- K8 v
│ exit code: 1+ }0 u7 l1 U/ G  k/ d+ Y. ~8 o) d
╰─> See above for output.
8 g; C0 }" w9 i' a; g, L6 ]
& \# u3 g/ g% D0 b$ q4 Z7 L# d6 ~note: This error originates from a subprocess, and is likely not a problem with pip.. M1 F/ q/ R+ K& b& ]
[root@python-flask ~]# pip install mysqlclient==2.1.09 ]+ r  O8 f! ]* H) U+ k, j3 [
Collecting mysqlclient==2.1.06 q( _+ ^! ?$ t7 }
  Downloading mysqlclient-2.1.0.tar.gz (87 kB)
& V  P: J7 a  T! \4 h& z     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 87.6/87.6 kB 635.5 kB/s eta 0:00:004 {7 `# I* Q( j+ T7 s/ {0 n& h& ~/ [
  Installing build dependencies ... done: p8 M1 ~. ^+ j4 c2 X
  Getting requirements to build wheel ... done5 x: Y' k4 v4 y5 Z" O
  Preparing metadata (pyproject.toml) ... done
: g! x' R2 o) ?  I7 b6 Y) aBuilding wheels for collected packages: mysqlclient
: z: G) ^. t% Y  Building wheel for mysqlclient (pyproject.toml) ... done$ V' a8 B1 h/ b( B1 q
  Created wheel for mysqlclient: filename=mysqlclient-2.1.0-cp312-cp312-linux_x86_64.whl size=102434 sha256=9195914c669fe1b57f256214d711095c10e05799fdf3b2033541f88830a69b6d( C9 Q4 {& D, F" q$ M& ?- M
  Stored in directory: /root/.cache/pip/wheels/b1/b6/8d/eb165ad207cde6784a606ec0a5bdd7a5b5c9241bad361d1623
& s2 J; p5 }. ^2 ?' d; J' cSuccessfully built mysqlclient
# d% u) y3 n  r* TInstalling collected packages: mysqlclient
& [, g; Q- H7 vSuccessfully installed mysqlclient-2.1.0/ H. v9 o4 L& [- Y' [' [; ~# r
WARNING: 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.
0 U9 k$ ?7 ?4 y' k

1

主题

0

回帖

12

积分

管理员

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

本版积分规则

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

GMT+8, 2026-6-12 01:56 , Processed in 0.024853 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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