我想使用带有 ARA 的 mysql 引擎/数据库,而不是工具附带的默认 sqlite 引擎,以便拥有一个用于多个条目的更强大的引擎,但我遇到一个问题,不允许我在下面的详细信息中实现这一点:
当我在 ARA 服务器的 settings.yml 文件中指定 mysql 引擎时出现以下错误:
~/.ara/server # [ara] Using settings file: /root/.ara/server/settings.yaml
Traceback (most recent call last):
File "/root/.local/lib/python3.8/site-packages/ara/server/__main__.py", line 54, in main
import MySQLdb # noqa
ModuleNotFoundError: No module named 'MySQLdb'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/root/.local/bin/ara-manage", line 8, in <module>
sys.exit(main())
File "/root/.local/lib/python3.8/site-packages/ara/server/__main__.py", line 56, in main
raise MissingMysqlclientException from e
ara.setup.exceptions.MissingMysqlclientException: The mysqlclient python library must be installed in order to use the MySQL database engine.
因此我检查了 mysqlclient 是否已安装,但显然没有安装:
~/.ara/server # pip3 list installed | grep mysql
但是当我尝试安装它时,我遇到了这个巨大的异常块:
~/.ara/server # pip3.8 install mysqlclient
Collecting mysqlclient
Using cached mysqlclient-2.0.3.tar.gz (88 kB)
Building wheels for collected packages: mysqlclient
Building wheel for mysqlclient (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-oq1ay19g/mysqlclient_f0ad3d21508f4b698b4bfb4e7c70b25d/setup.py'"'"'; __file__='"'"'/tmp/pip-install-oq1ay19g/mysqlclient_f0ad3d21508f4b698b4bfb4e7c70b25d/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-lm119tma
cwd: /tmp/pip-install-oq1ay19g/mysqlclient_f0ad3d21508f4b698b4bfb4e7c70b25d/
Complete output (41 lines):
mysql_config --version
['10.5.5']
mysql_config --libs
['-L/usr/lib/', '-lmariadb']
mysql_config --cflags
['-I/usr/include/mysql', '-I/usr/include/mysql/mysql']
ext_options:
library_dirs: ['/usr/lib/']
libraries: ['mariadb']
extra_compile_args: ['-std=c99']
extra_link_args: []
include_dirs: ['/usr/include/mysql', '/usr/include/mysql/mysql']
extra_objects: []
define_macros: [('version_info', "(2,0,3,'final',0)"), ('__version__', '2.0.3')]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.8/MySQLdb
copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-3.8/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.8/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.8/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.8/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.8/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.8/MySQLdb
creating build/lib.linux-x86_64-3.8/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
running build_ext
building 'MySQLdb._mysql' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/MySQLdb
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fomit-frame-pointer -g -fno-semantic-interposition -fomit-frame-pointer -g -fno-semantic-interposition -fomit-frame-pointer -g -fno-semantic-interposition -DTHREAD_STACK_SIZE=0x100000 -fPIC -Dversion_info=(2,0,3,'final',0) -D__version__=2.0.3 -I/usr/include/mysql -I/usr/include/mysql/mysql -I/usr/include/python3.8 -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.8/MySQLdb/_mysql.o -std=c99
unable to execute 'gcc': No such file or directory
error: command 'gcc' failed with exit status 1
----------------------------------------
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: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-oq1ay19g/mysqlclient_f0ad3d21508f4b698b4bfb4e7c70b25d/setup.py'"'"'; __file__='"'"'/tmp/pip-install-oq1ay19g/mysqlclient_f0ad3d21508f4b698b4bfb4e7c70b25d/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-ksqr0pbp/install-record.txt --single-version-externally-managed --compile --install-headers /usr/include/python3.8/mysqlclient
cwd: /tmp/pip-install-oq1ay19g/mysqlclient_f0ad3d21508f4b698b4bfb4e7c70b25d/
Complete output (41 lines):
mysql_config --version
['10.5.5']
mysql_config --libs
['-L/usr/lib/', '-lmariadb']
mysql_config --cflags
['-I/usr/include/mysql', '-I/usr/include/mysql/mysql']
ext_options:
library_dirs: ['/usr/lib/']
libraries: ['mariadb']
extra_compile_args: ['-std=c99']
extra_link_args: []
include_dirs: ['/usr/include/mysql', '/usr/include/mysql/mysql']
extra_objects: []
define_macros: [('version_info', "(2,0,3,'final',0)"), ('__version__', '2.0.3')]
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.8
creating build/lib.linux-x86_64-3.8/MySQLdb
copying MySQLdb/__init__.py -> build/lib.linux-x86_64-3.8/MySQLdb
copying MySQLdb/_exceptions.py -> build/lib.linux-x86_64-3.8/MySQLdb
copying MySQLdb/connections.py -> build/lib.linux-x86_64-3.8/MySQLdb
copying MySQLdb/converters.py -> build/lib.linux-x86_64-3.8/MySQLdb
copying MySQLdb/cursors.py -> build/lib.linux-x86_64-3.8/MySQLdb
copying MySQLdb/release.py -> build/lib.linux-x86_64-3.8/MySQLdb
copying MySQLdb/times.py -> build/lib.linux-x86_64-3.8/MySQLdb
creating build/lib.linux-x86_64-3.8/MySQLdb/constants
copying MySQLdb/constants/__init__.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
copying MySQLdb/constants/CLIENT.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
copying MySQLdb/constants/CR.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
copying MySQLdb/constants/ER.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
copying MySQLdb/constants/FIELD_TYPE.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
copying MySQLdb/constants/FLAG.py -> build/lib.linux-x86_64-3.8/MySQLdb/constants
running build_ext
building 'MySQLdb._mysql' extension
creating build/temp.linux-x86_64-3.8
creating build/temp.linux-x86_64-3.8/MySQLdb
gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fomit-frame-pointer -g -fno-semantic-interposition -fomit-frame-pointer -g -fno-semantic-interposition -fomit-frame-pointer -g -fno-semantic-interposition -DTHREAD_STACK_SIZE=0x100000 -fPIC -Dversion_info=(2,0,3,'final',0) -D__version__=2.0.3 -I/usr/include/mysql -I/usr/include/mysql/mysql -I/usr/include/python3.8 -c MySQLdb/_mysql.c -o build/temp.linux-x86_64-3.8/MySQLdb/_mysql.o -std=c99
unable to execute 'gcc': No such file or directory
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-oq1ay19g/mysqlclient_f0ad3d21508f4b698b4bfb4e7c70b25d/setup.py'"'"'; __file__='"'"'/tmp/pip-install-oq1ay19g/mysqlclient_f0ad3d21508f4b698b4bfb4e7c70b25d/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-ksqr0pbp/install-record.txt --single-version-externally-managed --compile --install-headers /usr/include/python3.8/mysqlclient Check the logs for full command output.
如果我理解错误,那么由于缺少 gcc,就会出现编译问题。但是当我尝试使用 pip 卸载 gcc7 时,它不起作用:
~/.ara/server # pip3 install gcc7
ERROR: Could not find a version that satisfies the requirement gcc7
ERROR: No matching distribution found for gcc7
1-那么我的分析正确吗?
2- 这背后的真正问题是什么?我的意思是是否有其他依赖项可能导致此问题。任何帮助或提示都将不胜感激。
附言:我正在研究高山分布。
答案1
我最终设法安装这两个包并使它工作:
apk add musl-dev gcc
在使用 gcc 时,Alpine 非常特殊,因此安装 musl-dev 可以解决问题。
答案2
如果我理解错误的话,那么由于缺少,存在编译问题
gcc
。
我不熟悉 Alpine Linux,但是从错误信息来看,你似乎没有可识别的版本gcc
(GNU 编译器集合)。
当我尝试
gcc7
使用安装时pip
,它不起作用。
尽管gcc7
似乎是一个有效的 Python 模块可通过pip
,它似乎是仅限 Mac此时。
任何帮助或提示都将不胜感激。
您可能想要尝试的第一件事是gcc
自己安装 Alpine Linux(在 之外pip
),假设它尚未可用。 请注意,Alpine Linux wiki 上有一些关于如何进行基本安装的简单说明gcc
。他们显然建议运行:
apk add build-base
“开始使用” gcc
(即拥有它和一些可用的基本库)。
gcc
请注意,即使安装正确,您仍然可能(理论上)遇到其他构建问题。