失败的PIP安装mysqlClclient在Ubuntu 20.04上使用Python 3.10

发布于 2025-01-28 13:42:47 字数 7801 浏览 3 评论 0原文

我正在尝试使用PIP安装mySqlClient,但它一直给我错误消息, 我已经从sudo apt-get install python3-dev默认default-libmysqlclient-dev build-Essential, 或使用此步骤: ldflags = -l/usr/local/opt/openssl/lib pip安装mysqlclient,此sudo apt-apt-get install libmariadb-dev-dev-dev-dev-compat libmariadb-dev libssl-dev libssl-code> libssl-code> libssl-code>

最后,我总是得到这个:为mySqlClient(setup.py)构建轮子...错误错误:子过程 - 访问 - with-error,我使用python ver 3.10.4作为主要,但是我还有另一个版本(2.7.18、3.8.10和3.9.5),

如果我尝试使用anaconda下载pip install mysqlclient,这会导致其他问题,因为我已经有python?

这是我的整个输出

Collecting mysqlclient
  Using cached mysqlclient-2.1.0.tar.gz (87 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: mysqlclient
  Building wheel for mysqlclient (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [44 lines of output]
      mysql_config --version
      ['10.4.24']
      mysql_config --libs
      ['-L/opt/lampp/lib/', '-lmariadb']
      mysql_config --cflags
      ['-I/opt/lampp/include/mysql', '-I/opt/lampp/include/mysql/mysql']
      ext_options:
        library_dirs: ['/opt/lampp/lib/']
        libraries: ['mariadb']
        extra_compile_args: ['-std=c99']
        extra_link_args: []
        include_dirs: ['/opt/lampp/include/mysql', '/opt/lampp/include/mysql/mysql']
        extra_objects: []
        define_macros: [('version_info', "(2,1,0,'final',0)"), ('__version__', '2.1.0')]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-310
      creating build/lib.linux-x86_64-cpython-310/MySQLdb
      copying MySQLdb/__init__.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
      copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
      copying MySQLdb/connections.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
      copying MySQLdb/converters.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
      copying MySQLdb/cursors.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
      copying MySQLdb/release.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
      copying MySQLdb/times.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
      creating build/lib.linux-x86_64-cpython-310/MySQLdb/constants
      copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
      copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
      copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
      copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
      copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
      copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
      running build_ext
      building 'MySQLdb._mysql' extension
      creating build/temp.linux-x86_64-cpython-310
      creating build/temp.linux-x86_64-cpython-310/MySQLdb
      x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Dversion_info=(2,1,0,'final',0) -D__version__=2.1.0 -I/opt/lampp/include/mysql -I/opt/lampp/include/mysql/mysql -I/home/aqila/venv/include -I/usr/include/python3.10 -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-cpython-310/MySQLdb/_mysql.o -std=c99
      MySQLdb/_mysql.c:29:10: fatal error: mysql.h: No such file or directory
         29 | #include "mysql.h"
            |          ^~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for mysqlclient
  Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
  Running setup.py install for mysqlclient ... error
  error: subprocess-exited-with-error
  
  × Running setup.py install for mysqlclient did not run successfully.
  │ exit code: 1
  ╰─> [46 lines of output]
      mysql_config --version
      ['10.4.24']
      mysql_config --libs
      ['-L/opt/lampp/lib/', '-lmariadb']
      mysql_config --cflags
      ['-I/opt/lampp/include/mysql', '-I/opt/lampp/include/mysql/mysql']
      ext_options:
        library_dirs: ['/opt/lampp/lib/']
        libraries: ['mariadb']
        extra_compile_args: ['-std=c99']
        extra_link_args: []
        include_dirs: ['/opt/lampp/include/mysql', '/opt/lampp/include/mysql/mysql']
        extra_objects: []
        define_macros: [('version_info', "(2,1,0,'final',0)"), ('__version__', '2.1.0')]
      running install
      /home/aqila/venv/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-310
      creating build/lib.linux-x86_64-cpython-310/MySQLdb
      copying MySQLdb/__init__.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
      copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
      copying MySQLdb/connections.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
      copying MySQLdb/converters.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
      copying MySQLdb/cursors.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
      copying MySQLdb/release.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
      copying MySQLdb/times.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
      creating build/lib.linux-x86_64-cpython-310/MySQLdb/constants
      copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
      copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
      copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
      copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
      copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
      copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
      running build_ext
      building 'MySQLdb._mysql' extension
      creating build/temp.linux-x86_64-cpython-310
      creating build/temp.linux-x86_64-cpython-310/MySQLdb
      x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Dversion_info=(2,1,0,'final',0) -D__version__=2.1.0 -I/opt/lampp/include/mysql -I/opt/lampp/include/mysql/mysql -I/home/aqila/venv/include -I/usr/include/python3.10 -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-cpython-310/MySQLdb/_mysql.o -std=c99
      MySQLdb/_mysql.c:29:10: fatal error: mysql.h: No such file or directory
         29 | #include "mysql.h"
            |          ^~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> mysqlclient

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.```

I am trying to install mysqlclient with pip but it keeps giving me error message,
I already have the development from sudo apt-get install python3-dev default-libmysqlclient-dev build-essential,
or use this step :
LDFLAGS=-L/usr/local/opt/openssl/lib pip install mysqlclient, and this sudo apt-get install libmariadb-dev-compat libmariadb-dev libssl-dev

and in the end i always get this : Building wheel for mysqlclient (setup.py) ... error error: subprocess-exited-with-error, i use python ver 3.10.4 as main, but i have another version (2.7.18, 3.8.10 and 3.9.5),

if i try to download pip install mysqlclient using anaconda, will it cause other problems because i already have python?

this is my whole output

Collecting mysqlclient
  Using cached mysqlclient-2.1.0.tar.gz (87 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: mysqlclient
  Building wheel for mysqlclient (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [44 lines of output]
      mysql_config --version
      ['10.4.24']
      mysql_config --libs
      ['-L/opt/lampp/lib/', '-lmariadb']
      mysql_config --cflags
      ['-I/opt/lampp/include/mysql', '-I/opt/lampp/include/mysql/mysql']
      ext_options:
        library_dirs: ['/opt/lampp/lib/']
        libraries: ['mariadb']
        extra_compile_args: ['-std=c99']
        extra_link_args: []
        include_dirs: ['/opt/lampp/include/mysql', '/opt/lampp/include/mysql/mysql']
        extra_objects: []
        define_macros: [('version_info', "(2,1,0,'final',0)"), ('__version__', '2.1.0')]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-310
      creating build/lib.linux-x86_64-cpython-310/MySQLdb
      copying MySQLdb/__init__.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
      copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
      copying MySQLdb/connections.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
      copying MySQLdb/converters.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
      copying MySQLdb/cursors.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
      copying MySQLdb/release.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
      copying MySQLdb/times.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
      creating build/lib.linux-x86_64-cpython-310/MySQLdb/constants
      copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
      copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
      copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
      copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
      copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
      copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
      running build_ext
      building 'MySQLdb._mysql' extension
      creating build/temp.linux-x86_64-cpython-310
      creating build/temp.linux-x86_64-cpython-310/MySQLdb
      x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Dversion_info=(2,1,0,'final',0) -D__version__=2.1.0 -I/opt/lampp/include/mysql -I/opt/lampp/include/mysql/mysql -I/home/aqila/venv/include -I/usr/include/python3.10 -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-cpython-310/MySQLdb/_mysql.o -std=c99
      MySQLdb/_mysql.c:29:10: fatal error: mysql.h: No such file or directory
         29 | #include "mysql.h"
            |          ^~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for mysqlclient
  Running setup.py clean for mysqlclient
Failed to build mysqlclient
Installing collected packages: mysqlclient
  Running setup.py install for mysqlclient ... error
  error: subprocess-exited-with-error
  
  × Running setup.py install for mysqlclient did not run successfully.
  │ exit code: 1
  ╰─> [46 lines of output]
      mysql_config --version
      ['10.4.24']
      mysql_config --libs
      ['-L/opt/lampp/lib/', '-lmariadb']
      mysql_config --cflags
      ['-I/opt/lampp/include/mysql', '-I/opt/lampp/include/mysql/mysql']
      ext_options:
        library_dirs: ['/opt/lampp/lib/']
        libraries: ['mariadb']
        extra_compile_args: ['-std=c99']
        extra_link_args: []
        include_dirs: ['/opt/lampp/include/mysql', '/opt/lampp/include/mysql/mysql']
        extra_objects: []
        define_macros: [('version_info', "(2,1,0,'final',0)"), ('__version__', '2.1.0')]
      running install
      /home/aqila/venv/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
        warnings.warn(
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-310
      creating build/lib.linux-x86_64-cpython-310/MySQLdb
      copying MySQLdb/__init__.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
      copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
      copying MySQLdb/connections.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
      copying MySQLdb/converters.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
      copying MySQLdb/cursors.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
      copying MySQLdb/release.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
      copying MySQLdb/times.py -> build/lib.linux-x86_64-cpython-310/MySQLdb
      creating build/lib.linux-x86_64-cpython-310/MySQLdb/constants
      copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
      copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
      copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
      copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
      copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
      copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-cpython-310/MySQLdb/constants
      running build_ext
      building 'MySQLdb._mysql' extension
      creating build/temp.linux-x86_64-cpython-310
      creating build/temp.linux-x86_64-cpython-310/MySQLdb
      x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -Dversion_info=(2,1,0,'final',0) -D__version__=2.1.0 -I/opt/lampp/include/mysql -I/opt/lampp/include/mysql/mysql -I/home/aqila/venv/include -I/usr/include/python3.10 -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-cpython-310/MySQLdb/_mysql.o -std=c99
      MySQLdb/_mysql.c:29:10: fatal error: mysql.h: No such file or directory
         29 | #include "mysql.h"
            |          ^~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> mysqlclient

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.```

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我是男神闪亮亮 2025-02-04 13:42:47

我刚刚遇到了同样的问题,使用PIP安装mySqlClient时会收到错误消息。经过一些搜索后,我发现了此博客文章。在博客文章之后,我们需要安装几个库:

sudo apt-get install python3.10-dev
sudo apt-get install mysql-client
sudo apt-get install libmysqlclient-dev
sudo apt-get install libssl-dev

成功安装上述库后,我们可以以这样的方式安装mysqlclient:

pip install mysqlclient

它对我有用。

I've just encountered the same problem, getting error messages when installing mysqlclient using pip. After some searches, I found this blog post. Following the blog post, we need to install several libraries:

sudo apt-get install python3.10-dev
sudo apt-get install mysql-client
sudo apt-get install libmysqlclient-dev
sudo apt-get install libssl-dev

After successfully install the above libraries, then we can install mysqlclient like this:

pip install mysqlclient

It works for me.

倾其所爱 2025-02-04 13:42:47

这就是我在2023年做到的:

从mySqlClient repo 他们提到要安装这些依赖关系,

sudo apt-get install python3-dev default-libmysqlclient-dev build-essential pkg-config

我认为我认为<<<代码> pkg-config 在这里很重要。

This is how I did it in 2023:

From the mysqlclient repo they mentioned to install these dependencies

sudo apt-get install python3-dev default-libmysqlclient-dev build-essential pkg-config

I think the pkg-config is important here.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文