易陆发现互联网技术论坛

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

pip install mysqlclient错误提示

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

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

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

x
pip install mysqlclient8 W, ]% E. O; t$ v
Collecting mysqlclient1 m% i7 R6 P3 J
  Using cached mysqlclient-2.2.4.tar.gz (90 kB)
' b: Q3 \$ ^* P' l1 O- Q& z  Installing build dependencies ... done" C) P4 q8 w' N
  Getting requirements to build wheel ... done
/ o1 p! X( O' D  Preparing metadata (pyproject.toml) ... done
  ?8 D# E! B/ m2 P! K- \' @Building wheels for collected packages: mysqlclient
) K: t+ Q- J2 b' G; P  Building wheel for mysqlclient (pyproject.toml) ... error
8 Z0 ^( m) T! V2 ?0 g1 R  error: subprocess-exited-with-error3 _" ?# l1 _& m% Z$ \7 D' u; C+ ~
& ]1 G, Q# {5 D
  × Building wheel for mysqlclient (pyproject.toml) did not run successfully.4 k2 F& Q4 c# n6 d& {
  │ exit code: 1. y+ [6 g: ?3 a& K
  ╰─> [63 lines of output]
4 _9 Q/ L( v* f% v; }      # Options for building extension module:
3 ]" \# ?) n0 C9 o6 A        extra_compile_args: ['-I/usr/include/mysql', '-std=c99']
" }! E6 E7 b$ M# X+ a& O        extra_link_args: ['-L/usr/lib/x86_64-linux-gnu']
9 Q, e( }: o" |5 A/ W        define_macros: [('version_info', (2, 2, 4, 'final', 0)), ('__version__', '2.2.4')]
. J$ k$ _8 H$ Y) h! I      running bdist_wheel( E' i$ i) U1 U
      running build
8 N! t# Y( I$ k: h6 X  y: H) v% e! J      running build_py
. l$ J- m$ J$ ^      creating build$ _! ~' n4 P1 f* K6 ]6 |. R
      creating build/lib.linux-x86_64-cpython-312
$ _: ^3 E/ [) r7 b7 F) _      creating build/lib.linux-x86_64-cpython-312/MySQLdb
$ @" R  s4 E. \5 X; f& |! n% O6 H( B      copying src/MySQLdb/__init__.py -> build/lib.linux-x86_64-cpython-312/MySQLdb, X( G& n$ Q1 {  O+ c! N  ~
      copying src/MySQLdb/_exceptions.py -> build/lib.linux-x86_64-cpython-312/MySQLdb
1 @1 @* Q0 \* y' X6 q& X1 l1 k4 a      copying src/MySQLdb/connections.py -> build/lib.linux-x86_64-cpython-312/MySQLdb
9 p3 ]! X. ?' Q# c) g9 w      copying src/MySQLdb/converters.py -> build/lib.linux-x86_64-cpython-312/MySQLdb! x5 o& n, W& ~' N6 \5 N3 l
      copying src/MySQLdb/cursors.py -> build/lib.linux-x86_64-cpython-312/MySQLdb
  o/ k5 v4 f) f# l/ `2 `: J      copying src/MySQLdb/release.py -> build/lib.linux-x86_64-cpython-312/MySQLdb0 ]- x% `. U; s! b5 k
      copying src/MySQLdb/times.py -> build/lib.linux-x86_64-cpython-312/MySQLdb$ I/ G  u" p  _
      creating build/lib.linux-x86_64-cpython-312/MySQLdb/constants
) r8 k/ N! M3 i7 E# }3 L6 ?6 E' O      copying src/MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants3 {4 `! ^, ?; ]$ b# s( `' A
      copying src/MySQLdb/constants/CR.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants
  Z. s% w2 @/ n      copying src/MySQLdb/constants/ER.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants5 O; C0 }  Z+ `4 B  o
      copying src/MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants
" W( o( M" [6 ~* ?# o: |      copying src/MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants( w& F6 p5 z3 N  d" q7 G
      copying src/MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-cpython-312/MySQLdb/constants
8 k: w, _/ Z# }" g% i      running egg_info
& b" g+ g3 }" L; s8 I9 T6 Q4 R3 L      writing src/mysqlclient.egg-info/PKG-INFO- s( i) }! o2 w* G5 a- S
      writing dependency_links to src/mysqlclient.egg-info/dependency_links.txt: w" |; C8 ^. i( q6 ^! k7 V6 x
      writing top-level names to src/mysqlclient.egg-info/top_level.txt
6 N/ }/ F0 b6 {6 D2 C! w4 A2 ~      reading manifest file 'src/mysqlclient.egg-info/SOURCES.txt'
  h7 X0 |3 u1 a6 V+ ?: P) A      reading manifest template 'MANIFEST.in'- E/ V: G2 q, i& t8 T/ F4 b1 x
      adding license file 'LICENSE'# H8 ^$ S) P2 C1 u; b
      writing manifest file 'src/mysqlclient.egg-info/SOURCES.txt'
0 ~! P2 t7 j3 Z  p6 B9 y5 i      copying src/MySQLdb/_mysql.c -> build/lib.linux-x86_64-cpython-312/MySQLdb
' _; d4 v7 J  }3 J6 G      running build_ext
$ b- ^2 w* m% L- M2 }* y      building 'MySQLdb._mysql' extension4 l1 U1 H, Z/ S6 D
      creating build/temp.linux-x86_64-cpython-312
7 o9 \4 _# X/ V! ]& }8 |! c' t      creating build/temp.linux-x86_64-cpython-312/src
7 |0 v& [/ m! G" d( K8 G8 t& |      creating build/temp.linux-x86_64-cpython-312/src/MySQLdb
) q. G: I+ I) m- y' Y5 b      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 z! C" A( G6 Z$ `" M      src/MySQLdb/_mysql.c: 在函数‘_mysql_ConnectionObject_Initialize’中:
% S0 Y. l, \0 D: L      src/MySQLdb/_mysql.c:539:44: 错误:‘MYSQL_OPT_SSL_KEY’未声明(在此函数内第一次使用)/ F5 Q" f6 v% b7 s, j0 B
               mysql_options(&(self->connection), MYSQL_OPT_SSL_KEY, key);6 k9 e" H; f8 Y. E% W- l5 X3 \
                                                  ^; Z: L+ P8 }- h
      src/MySQLdb/_mysql.c:539:44: 附注:每个未声明的标识符在其出现的函数内只报告一次
- {% G9 D3 i* O; \      src/MySQLdb/_mysql.c:540:44: 错误:‘MYSQL_OPT_SSL_CERT’未声明(在此函数内第一次使用)2 ~1 A) p+ B: G5 |
               mysql_options(&(self->connection), MYSQL_OPT_SSL_CERT, cert);/ Q# D% W" b8 I; _- {2 o( P. q
                                                  ^
$ R9 }: L: m. w9 m      src/MySQLdb/_mysql.c:541:44: 错误:‘MYSQL_OPT_SSL_CA’未声明(在此函数内第一次使用)- s; U4 a5 o! B! _7 a4 r. U
               mysql_options(&(self->connection), MYSQL_OPT_SSL_CA, ca);/ Z: }( _% q  n
                                                  ^
" D; E; l3 C6 L# o      src/MySQLdb/_mysql.c:542:44: 错误:‘MYSQL_OPT_SSL_CAPATH’未声明(在此函数内第一次使用)
- j: t8 G( f2 E, D% t2 D0 B+ h               mysql_options(&(self->connection), MYSQL_OPT_SSL_CAPATH, capath);
# U% E" P5 m: z! X                                                  ^
! u7 |+ H8 Q% ?$ G" p* R* Y      src/MySQLdb/_mysql.c:543:44: 错误:‘MYSQL_OPT_SSL_CIPHER’未声明(在此函数内第一次使用)% Y5 f9 Q7 ?9 v0 n. B) x
               mysql_options(&(self->connection), MYSQL_OPT_SSL_CIPHER, cipher);
/ C5 P+ f3 t! j) b+ o& `: n                                                  ^
. d+ T  J& ~5 }, b  b      src/MySQLdb/_mysql.c:556:13: 警告:隐式声明函数‘mysql_optionsv’ [-Wimplicit-function-declaration]% _0 }! C5 H" M- H2 C5 n1 M
                   mysql_optionsv(&(self->connection), MYSQL_OPT_SSL_ENFORCE, (void *)&enforce_tls);
& R. {# Y& _- Y9 W                   ^) T, O& i/ r* i( e1 i: T& P
      src/MySQLdb/_mysql.c:556:49: 错误:‘MYSQL_OPT_SSL_ENFORCE’未声明(在此函数内第一次使用)
+ t  X, i# f0 V  D6 ]                   mysql_optionsv(&(self->connection), MYSQL_OPT_SSL_ENFORCE, (void *)&enforce_tls);
3 }4 C0 Q4 l, w9 V9 `1 Z                                                       ^+ I) r# a7 \& X. ^3 E
      error: command '/usr/bin/gcc' failed with exit code 1# j: Z1 k" n+ \
      [end of output]7 ]" p$ t" f6 }" u" ?, _
) G$ x: X: M2 k% R0 m
  note: This error originates from a subprocess, and is likely not a problem with pip.5 B5 j! |3 Q' `, ^6 E
  ERROR: Failed building wheel for mysqlclient
9 L- E3 m& x4 n. x9 L3 gFailed to build mysqlclient5 y0 t& }6 e2 E# J0 n
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (mysqlclient)
% u9 t$ |) w/ V4 H3 y0 l5 z/ c4 t2 S. H0 u: r# H/ o
2 ~; R1 ]4 t. a+ W) `8 X4 ]& d) a
! l- h4 G$ U' N2 }# s' k$ `& D

" A3 N$ d! Z  d* b' O$ O9 z9 @解决方法:
; T9 X: w9 B5 y! x6 S0 [8 w# v0 z" p9 n' }5 q
降低mysqlclient 版本,替换mysqlclient-2.0.2 为1:! m: W8 p7 l1 f  V) I1 h

4 `! B: }( N& Oapache-airflow-providers-mysql==5.4.00 D" K% p- r' `- s' f( b
mysqlclient==2.1.01 ^' ]' Q5 |% _. U$ O5 d$ }6 A, @

7 K; e/ R+ Q9 o3 @$ ]  C$ C  w$ p" v1 J) `5 t
( t0 ^& c' h, O" [2 X, c
 楼主| 发表于 2024-7-27 21:00:06 | 显示全部楼层
[root@python-flask ~]# pip install mysqlclient
+ V9 P6 n. V5 K8 j3 x( s2 oCollecting mysqlclient
- @0 {9 R9 H! b! n( H9 B  v  Using cached mysqlclient-2.2.4.tar.gz (90 kB)
+ t1 c0 S2 a" Z+ m  Installing build dependencies ... done3 ~, [. n' U" }/ E" \. Y
  Getting requirements to build wheel ... error, D; c) O1 T; w; F
  error: subprocess-exited-with-error  s0 {, C  W* q& N) D# f) z% y( X
  
* x4 h5 j+ a& D! @  × Getting requirements to build wheel did not run successfully.
' X' \/ d7 M3 ^! _  |. ~  │ exit code: 1
* {) A9 ?  q% P( o, h) a+ ?' ^  ╰─> [27 lines of output]$ y2 n3 C. Y$ o' \4 v
      Trying pkg-config --exists mysqlclient
) V$ C% c" T2 W& l* }  F( C: Q      Command 'pkg-config --exists mysqlclient' returned non-zero exit status 1.4 E$ G: a6 p+ s8 g0 b
      Trying pkg-config --exists mariadb
% y% U1 k& [& Z9 x* [1 H      Command 'pkg-config --exists mariadb' returned non-zero exit status 1.
3 h9 p7 u4 ?1 N0 U! Y' K0 {      Trying pkg-config --exists libmariadb
0 }) u9 A. i7 {$ S% D* g! L! }  D" r      Command 'pkg-config --exists libmariadb' returned non-zero exit status 1.
+ y9 V( q1 P4 {1 b' d      Traceback (most recent call last):
4 d. J; I# ^$ x* Z7 C/ r        File "/usr/local/python312/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
( v0 `1 L; n: I5 X; A- I9 c8 v          main()7 h1 U: H/ A* K& x
        File "/usr/local/python312/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main0 E! d9 _$ d* h  @6 t
          json_out['return_val'] = hook(**hook_input['kwargs'])- H$ k5 W3 V4 X; M* y  Z0 _) L
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^( ]  n+ T: b4 H" r8 u% O
        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+ w0 N* I6 \( J9 n
          return hook(config_settings)
* c% f5 H, k( c! x/ W2 e& U; ~                 ^^^^^^^^^^^^^^^^^^^^^6 ?+ v, F& z' i3 J, M
        File "/tmp/pip-build-env-w2b8dsud/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 327, in get_requires_for_build_wheel# W; P( W1 x+ t
          return self._get_build_requires(config_settings, requirements=[])
  \. N/ @, F  k. a7 H. s- A& `                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6 G* w0 t" r  {' e7 B* Q        File "/tmp/pip-build-env-w2b8dsud/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 297, in _get_build_requires' h7 I- t# g8 O' F; J
          self.run_setup()* d1 D8 I7 u3 J" [
        File "/tmp/pip-build-env-w2b8dsud/overlay/lib/python3.12/site-packages/setuptools/build_meta.py", line 313, in run_setup. M) S( o% U" [
          exec(code, locals())8 G8 U& c( h/ q' y1 U
        File "<string>", line 155, in <module>' y1 ^' r! t$ l# V
        File "<string>", line 49, in get_config_posix
7 D% v) x4 @4 D+ Z4 V        File "<string>", line 28, in find_package_name/ A8 }  d8 O8 d. U
      Exception: Can not find valid pkg-config name.
" A" i3 t" e1 D2 p4 [6 t+ ]      Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually
- w; ~( P; W  V- u6 x( J      [end of output]
0 m% w' V# j) Z: E' {- h2 B$ n  
2 N8 k# o" l/ q- I% U9 s9 S  note: This error originates from a subprocess, and is likely not a problem with pip.7 ^( ]2 p3 E* {5 L$ f
error: subprocess-exited-with-error  T& [: E  v3 F' U6 z% t

7 y( f& Y6 |& g0 H! }× Getting requirements to build wheel did not run successfully.# b3 @4 S& M, L
│ exit code: 1  S4 K. R. o2 S* P% Q& p) h
╰─> See above for output.
8 W. M( ^. o2 G5 G; |' p& j; f+ a6 u5 B) S
note: This error originates from a subprocess, and is likely not a problem with pip.
' N: j- w5 z5 S! a. o- G[root@python-flask ~]# pip install mysqlclient==2.1.0
6 X% [- X3 p5 D$ sCollecting mysqlclient==2.1.0
! l: Q1 \& d0 O( S% Y* s  Downloading mysqlclient-2.1.0.tar.gz (87 kB)* T: m9 `  a( n& \: b- f3 g& v
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 87.6/87.6 kB 635.5 kB/s eta 0:00:00  f9 _6 b( y! |6 @1 X3 F5 A
  Installing build dependencies ... done
6 ?# e0 v+ u! v' }7 @7 |  Getting requirements to build wheel ... done; L$ Z$ q; b+ D+ `; K9 A
  Preparing metadata (pyproject.toml) ... done) w1 q- ?5 N, p/ I" g9 I
Building wheels for collected packages: mysqlclient
, v' x; i- a" u5 H. m& u) e& C0 Q  Building wheel for mysqlclient (pyproject.toml) ... done" ^! K( q0 B- M6 k( q
  Created wheel for mysqlclient: filename=mysqlclient-2.1.0-cp312-cp312-linux_x86_64.whl size=102434 sha256=9195914c669fe1b57f256214d711095c10e05799fdf3b2033541f88830a69b6d
& z$ N9 H: T2 _8 }$ a  Stored in directory: /root/.cache/pip/wheels/b1/b6/8d/eb165ad207cde6784a606ec0a5bdd7a5b5c9241bad361d16233 H+ c/ f: |# d
Successfully built mysqlclient
5 V1 o, f: {6 v) u* ~! z9 XInstalling collected packages: mysqlclient4 p0 d2 r- {9 Z& s1 q5 C
Successfully installed mysqlclient-2.1.00 x6 l' k$ v4 T/ B, \$ A! z
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.! O& V% p0 }  S% u1 W5 {) j% j
 楼主| 发表于 2024-7-30 02:02:53 | 显示全部楼层
安装失败还有一个原因可能是因为环境不干净导致。
您需要登录后才可以回帖 登录 | 开始注册

本版积分规则

关闭

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

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

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

GMT+8, 2026-4-8 21:27 , Processed in 0.047025 second(s), 22 queries .

Powered by Discuz! X3.4 Licensed

© 2012-2025 Discuz! Team.

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