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

pip install mysqlclient错误提示

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2024-7-27 21:00:05 | 显示全部楼层 |阅读模式
pip install mysqlclient7 o& V2 Y# R+ h+ [7 A! D0 e
Collecting mysqlclient
' m; m+ j2 k: q+ N6 t; B  Using cached mysqlclient-2.2.4.tar.gz (90 kB)
1 I3 G% u; a- B; n5 ~  Installing build dependencies ... done! a, _* y# l0 o! C% A. S
  Getting requirements to build wheel ... done
( [4 @  ~" w. |/ e  Preparing metadata (pyproject.toml) ... done  W% [4 g4 F5 K! [
Building wheels for collected packages: mysqlclient
  _0 u% y5 j" B) C8 U$ r! }3 r  Building wheel for mysqlclient (pyproject.toml) ... error
" b8 Z: l* U. {6 O6 x0 f( w5 y2 z  error: subprocess-exited-with-error: _* S6 ?$ G+ P

( i; {) }5 P- S. E) L1 S  × Building wheel for mysqlclient (pyproject.toml) did not run successfully.
8 l4 u4 o6 `! p% ?; ]" f1 }  │ exit code: 15 ?- @) R  h( T5 D% v: o, T
  ╰─> [63 lines of output]" O9 A' k$ x+ z" r7 O$ V3 K, p5 N
      # Options for building extension module:6 M" [  b! r# w! J" ]8 e+ W
        extra_compile_args: ['-I/usr/include/mysql', '-std=c99']. y; S, V! ^/ t
        extra_link_args: ['-L/usr/lib/x86_64-linux-gnu']
* l$ B3 a5 e5 |- ]) J% ^- v        define_macros: [('version_info', (2, 2, 4, 'final', 0)), ('__version__', '2.2.4')]
4 l- a  c. {# V! |      running bdist_wheel
: b" F9 q6 Z) N3 |1 {      running build. t5 c; |) B& n  U. n& y/ ?
      running build_py
& M* P9 U5 k1 s: D6 T. |- ]      creating build) P" {" l5 _1 }, g+ y# V) v& F
      creating build/lib.linux-x86_64-cpython-312
( u7 h, o9 v& Z6 K+ w* C      creating build/lib.linux-x86_64-cpython-312/MySQLdb
: f3 C9 @) {0 [1 X  j1 n      copying src/MySQLdb/__init__.py -> build/lib.linux-x86_64-cpython-312/MySQLdb* `0 q; }2 [' {+ K: V/ x
      copying src/MySQLdb/_exceptions.py -> build/lib.linux-x86_64-cpython-312/MySQLdb% Q, Z* w3 x, p
      copying src/MySQLdb/connections.py -> build/lib.linux-x86_64-cpython-312/MySQLdb
( {2 X! n5 c: [+ v      copying src/MySQLdb/converters.py -> build/lib.linux-x86_64-cpython-312/MySQLdb
3 U7 f5 R  E  J; N, C; ^1 t  p      copying src/MySQLdb/cursors.py -> build/lib.linux-x86_64-cpython-312/MySQLdb0 c* b6 j+ K; f6 M8 {  V$ A6 h
      copying src/MySQLdb/release.py -> build/lib.linux-x86_64-cpython-312/MySQLdb
  Z/ J# r0 q" A      copying src/MySQLdb/times.py -> build/lib.linux-x86_64-cpython-312/MySQLdb1 a9 k$ r6 ^# w% t
      creating build/lib.linux-x86_64-cpython-312/MySQLdb/constants
2 q. \3 N( ]2 y      copying src/MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants
3 R' ?. M/ a6 B. d. ~0 k' D' \% v      copying src/MySQLdb/constants/CR.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants
2 B# `* ?, I2 g  N- D      copying src/MySQLdb/constants/ER.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants
  R) J: v4 Z4 W' Y      copying src/MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants3 c8 M) ^+ ]" m. l  W, @
      copying src/MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants
  g6 ]& n0 k# e' X: G      copying src/MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants
3 @, C1 @* I' }5 W      running egg_info% ~4 _& ~. s4 s4 i
      writing src/mysqlclient.egg-info/PKG-INFO
9 |, J+ v/ f% {6 x/ s8 G; g      writing dependency_links to src/mysqlclient.egg-info/dependency_links.txt
0 F# s6 j3 _1 y9 B      writing top-level names to src/mysqlclient.egg-info/top_level.txt
" ~/ ^3 D3 w" y7 I      reading manifest file 'src/mysqlclient.egg-info/SOURCES.txt'
4 y6 Z  a* Z; i* l) R      reading manifest template 'MANIFEST.in'' r4 q, J- a8 g3 L& q" F4 [' z
      adding license file 'LICENSE'# @5 k( M* H& w) s/ M! J
      writing manifest file 'src/mysqlclient.egg-info/SOURCES.txt'
" ]+ J8 `. }) ^& u. E      copying src/MySQLdb/_mysql.c -> build/lib.linux-x86_64-cpython-312/MySQLdb! u" u, n& p$ k) d$ w  U: J! R
      running build_ext: o/ n* d* ?9 |7 r! a' a
      building 'MySQLdb._mysql' extension
7 ^' r: @! E2 a% |      creating build/temp.linux-x86_64-cpython-3127 U4 r  Z. O$ m. e, Z4 y0 e
      creating build/temp.linux-x86_64-cpython-312/src
( F) }: q3 X* q' A# h& Z1 J      creating build/temp.linux-x86_64-cpython-312/src/MySQLdb3 p' p% _1 o/ p9 b8 o: W' R' f& Z2 f# g
      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=c997 N- F* Q6 A! J$ t! T
      src/MySQLdb/_mysql.c: 在函数‘_mysql_ConnectionObject_Initialize’中:5 s# \9 @+ |: c" R' r& f1 X
      src/MySQLdb/_mysql.c:539:44: 错误:‘MYSQL_OPT_SSL_KEY’未声明(在此函数内第一次使用)
- T9 j& B7 {% L' [8 @1 x9 v: |1 T               mysql_options(&(self->connection), MYSQL_OPT_SSL_KEY, key);6 q+ a5 U) r! t& c5 O
                                                  ^3 w" D# Y+ z7 t  R. P7 L7 G
      src/MySQLdb/_mysql.c:539:44: 附注:每个未声明的标识符在其出现的函数内只报告一次
- d! e; t, e3 Y4 n# ?      src/MySQLdb/_mysql.c:540:44: 错误:‘MYSQL_OPT_SSL_CERT’未声明(在此函数内第一次使用). c2 B* W% D! n4 N# D4 ]4 Y
               mysql_options(&(self->connection), MYSQL_OPT_SSL_CERT, cert);# v$ h0 G4 e; u9 Q
                                                  ^: \: u5 S! ?' F& u
      src/MySQLdb/_mysql.c:541:44: 错误:‘MYSQL_OPT_SSL_CA’未声明(在此函数内第一次使用)
/ d$ e- p- \2 O               mysql_options(&(self->connection), MYSQL_OPT_SSL_CA, ca);6 m! Y1 L0 G* o
                                                  ^( B+ l. _: |9 @2 H4 g
      src/MySQLdb/_mysql.c:542:44: 错误:‘MYSQL_OPT_SSL_CAPATH’未声明(在此函数内第一次使用)
2 ?; `5 O' q- w* e               mysql_options(&(self->connection), MYSQL_OPT_SSL_CAPATH, capath);
8 u7 L8 [# ?1 U                                                  ^! {+ ]( e8 C1 q
      src/MySQLdb/_mysql.c:543:44: 错误:‘MYSQL_OPT_SSL_CIPHER’未声明(在此函数内第一次使用)
$ \0 ~$ L& V/ h* J1 q" c9 K( ^4 s               mysql_options(&(self->connection), MYSQL_OPT_SSL_CIPHER, cipher);
, t- C/ ~& m6 p( p2 o6 y                                                  ^4 M# \3 n1 U+ C/ z* P% P
      src/MySQLdb/_mysql.c:556:13: 警告:隐式声明函数‘mysql_optionsv’ [-Wimplicit-function-declaration]
8 _' |3 j$ {6 o: r                   mysql_optionsv(&(self->connection), MYSQL_OPT_SSL_ENFORCE, (void *)&enforce_tls);
# w3 h6 P) U! ?                   ^5 x6 J% u' l# N( L! P! b
      src/MySQLdb/_mysql.c:556:49: 错误:‘MYSQL_OPT_SSL_ENFORCE’未声明(在此函数内第一次使用)
- W* _% H" f, M: M1 j$ \                   mysql_optionsv(&(self->connection), MYSQL_OPT_SSL_ENFORCE, (void *)&enforce_tls);. G# ?, {# Z4 i3 [7 s% p
                                                       ^
0 R% d4 D8 S% n+ m, k3 N0 k: K      error: command '/usr/bin/gcc' failed with exit code 1; `  @) V, H9 ^5 u
      [end of output]
  p& k* V% G% j/ a
2 [: O9 L9 e" C5 R1 _# H) {% ~  note: This error originates from a subprocess, and is likely not a problem with pip.1 k9 P. Z" \# m) w! }/ W& W- v# g/ Z
  ERROR: Failed building wheel for mysqlclient6 U$ ^# T% w8 W, f3 a
Failed to build mysqlclient$ H$ L4 I* e% S' s
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (mysqlclient)
/ P& x. e1 ?' \& ~3 ^/ ~$ U; H% c" R7 S  [0 O

3 h- u0 x% O4 h: d% d$ Y) Q5 B/ s7 Q+ t

4 {! J$ E# H5 Y/ ]3 p解决方法:2 v: G5 `; f9 k$ |$ f3 j
8 |! H% _  R- m& C3 {4 q- i
降低mysqlclient 版本,替换mysqlclient-2.0.2 为1:; u3 c: ?+ G% m8 V

" X- z6 k) e+ y) k5 N/ @& xapache-airflow-providers-mysql==5.4.0' ]. z& t2 T0 Z! g
mysqlclient==2.1.0
1 H+ Z  W' J/ X9 K: Q& i) o3 e* j' g) a7 s. p8 m0 i$ O% B

- ?8 c0 I" z- n3 u* k* }/ e: {* L8 X# j* E- o: R: P

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2024-7-27 21:00:06 | 显示全部楼层
[root@python-flask ~]# pip install mysqlclient
7 u9 J0 J6 S- {* h$ F0 aCollecting mysqlclient8 E' J9 P8 [7 [! C5 |$ ?# s' |
  Using cached mysqlclient-2.2.4.tar.gz (90 kB)3 ^* p) w5 z& Q4 a% o' R% M. M
  Installing build dependencies ... done
0 m4 n: B3 a$ h- M1 ?! |, b  Getting requirements to build wheel ... error
" G9 |  j" C1 k( ^0 c  f  error: subprocess-exited-with-error. r, B7 f- u' g; B5 s1 W7 E; W- o4 f$ v
  
/ C  B+ g/ H2 j; C2 ?: R& P8 `  × Getting requirements to build wheel did not run successfully.
7 O2 |7 j( v' t8 z  │ exit code: 1
# l/ v$ p) R9 ^; `( ]  ╰─> [27 lines of output]
( o0 h: ^6 W6 S& ?' H. C      Trying pkg-config --exists mysqlclient) u" E, H$ F+ B, ]  V9 T5 c* c+ e
      Command 'pkg-config --exists mysqlclient' returned non-zero exit status 1.
4 V, c) W5 ~# Q: p9 x; A3 }      Trying pkg-config --exists mariadb
+ [$ p+ I# e: h9 ~1 r      Command 'pkg-config --exists mariadb' returned non-zero exit status 1." x; U" Y; z% J9 u( F
      Trying pkg-config --exists libmariadb% h% b  T# K* G/ P6 J  P
      Command 'pkg-config --exists libmariadb' returned non-zero exit status 1.3 }( y0 B5 u! J% w. b6 P" S
      Traceback (most recent call last):
1 k: B8 l0 R6 O; `3 w        File "/usr/local/python312/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>6 \/ N0 j1 T) n* ]
          main()
/ J. u0 k8 m% j: v        File "/usr/local/python312/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main1 Y- e" a4 [6 c) o6 V+ f1 M3 V
          json_out['return_val'] = hook(**hook_input['kwargs'])
/ n2 Y$ x; M) w2 b                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1 D! V+ q9 m# K) [! l' x2 x        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
& T5 A/ d, x" x$ Q          return hook(config_settings)
3 D4 K0 Q( U# J9 C9 X                 ^^^^^^^^^^^^^^^^^^^^^
7 M8 u5 E6 y2 B' K! u- \5 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# t, t" T9 s# h% [8 b: k) N
          return self._get_build_requires(config_settings, requirements=[])5 A1 d# J' M3 {! R+ F7 U
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
$ p2 d8 C* c1 U' U# S/ L        File "/tmp/pip-build-env-w2b8dsud/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 297, in _get_build_requires
+ R8 N8 K( y$ H8 \. z6 v- g          self.run_setup()
5 W" Y% F0 A- }- r/ K  Y, q1 x        File "/tmp/pip-build-env-w2b8dsud/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 313, in run_setup' l/ v$ O; R% |$ T( ^
          exec(code, locals())# H7 K" D  }4 u! n" H
        File "<string>", line 155, in <module>" n, O3 w* `" X& `$ z- L1 i3 x" Z( V
        File "<string>", line 49, in get_config_posix2 u. m" B/ ?9 h$ Q# S% m
        File "<string>", line 28, in find_package_name7 ?, x. D5 _+ q* Z, u9 E, O
      Exception: Can not find valid pkg-config name.
: v" U1 u: C* [4 f/ I) \$ }  x      Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually% X' S5 X9 w6 c; y  p/ C8 G
      [end of output]( ^( a0 k7 Z' d6 l0 m" \
  
6 P  c& T" P  E  note: This error originates from a subprocess, and is likely not a problem with pip.% ~& c* p# g& G; s
error: subprocess-exited-with-error$ f. ]* @5 i, M- m

9 R# i1 D/ U8 w( L) b2 E× Getting requirements to build wheel did not run successfully.
9 ?' i9 S, a  q* }. ?' K│ exit code: 1
4 O3 H$ W0 C9 \6 r& I+ ~╰─> See above for output.) {2 y% I8 R& j( |- M1 b

2 x7 \4 D- E$ R  anote: This error originates from a subprocess, and is likely not a problem with pip.
* z+ ^- k# \- e; C2 t[root@python-flask ~]# pip install mysqlclient==2.1.0+ S( m: t! R( B- F
Collecting mysqlclient==2.1.03 J3 s) Q$ {. F6 H7 P& U7 s
  Downloading mysqlclient-2.1.0.tar.gz (87 kB)
6 ~2 {) J8 w2 j     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 87.6/87.6 kB 635.5 kB/s eta 0:00:00
! h: r3 v( L) r" Z  Installing build dependencies ... done% G" _6 T7 K5 ^' V* i
  Getting requirements to build wheel ... done; r0 `2 F3 d& T" T/ W
  Preparing metadata (pyproject.toml) ... done
& h) |0 M; D; n0 l7 OBuilding wheels for collected packages: mysqlclient) R/ U3 M, a* [$ u  \/ e: T+ P
  Building wheel for mysqlclient (pyproject.toml) ... done
# [9 O( p" V/ O; l! c; }' |7 u/ a( W  Created wheel for mysqlclient: filename=mysqlclient-2.1.0-cp312-cp312-linux_x86_64.whl size=102434 sha256=9195914c669fe1b57f256214d711095c10e05799fdf3b2033541f88830a69b6d, r* S; ?; x# z( c
  Stored in directory: /root/.cache/pip/wheels/b1/b6/8d/eb165ad207cde6784a606ec0a5bdd7a5b5c9241bad361d1623
$ p* G$ [1 @6 d7 vSuccessfully built mysqlclient
+ C6 |" W1 Z! `Installing collected packages: mysqlclient
. r; s* S7 {! l$ ~; J9 ~- HSuccessfully installed mysqlclient-2.1.06 j. T# W% W% I& A
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.7 p$ W( w5 T1 E- Z, N8 Q

1

主题

0

回帖

12

积分

管理员

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

本版积分规则

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

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

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

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