英文:
specify mysqlclient cflags and mysqlclient ldflags env vars manually while pip install apache-airflow-providers-mysql | Windows | no docker
问题
我正在尝试在我的虚拟环境中安装Airflow提供者。
pip install apache-airflow-providers-mysql
error: subprocess-exited-with-error
× 获取构建轮子所需的要求未成功运行。
│ 退出代码:1
╰─> [输出的 24 行]
/bin/sh: 1: pkg-config: 未找到命令
/bin/sh: 1: pkg-config: 未找到命令
正在尝试 pkg-config --exists mysqlclient
命令 'pkg-config --exists mysqlclient' 返回非零退出状态 127。
正在尝试 pkg-config --exists mariadb
命令 'pkg-config --exists mariadb' 返回非零退出状态 127。
追溯(最近的调用最后):
文件 "/home/user/airflow/airflow_env/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py",第 353 行,在 <module> 中
主函数()
文件 "/home/user/airflow/airflow_env/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py",第 335 行,在 main 中
json_out['return_val'] = hook(**hook_input['kwargs'])
文件 "/home/user/airflow/airflow_env/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py",第 118 行,在 get_requires_for_build_wheel 中
return hook(config_settings)
文件 "/tmp/pip-build-env-a5nk1xf1/overlay/lib/python3.10/site-packages/setuptools/build_meta.py",第 341 行,在 get_requires_for_build_wheel 中
return self._get_build_requires(config_settings, requirements=['wheel'])
文件 "/tmp/pip-build-env-a5nk1xf1/overlay/lib/python3.10/site-packages/setuptools/build_meta.py",第 323 行,在 _get_build_requires 中
self.run_setup()
文件 "/tmp/pip-build-env-a5nk1xf1/overlay/lib/python3.10/site-packages/setuptools/build_meta.py",第 338 行,在 run_setup 中
exec(code, locals())
文件 "<string>", 第 154 行,在 <module> 中
文件 "<string>", 第 48 行,在 get_config_posix 中
文件 "<string>", 第 27 行,在 find_package_name 中
异常:找不到有效的 pkg-config 名称。
请手动指定 MYSQLCLIENT_CFLAGS 和 MYSQLCLIENT_LDFLAGS 环境变量
[输出结束]
注意:此错误来自子进程,可能与 pip 无关。
error: subprocess-exited-with-error
× 获取构建轮子所需的要求未成功运行。
│ 退出代码:1
╰─> 请查看上述输出。
期望在Airflow连接下拉菜单中看到MySQL提供者。
已尝试以下选项:https://stackoverflow.com/questions/66441854/cannot-install-apache-airflow-providers-mysql-1-0-0-and-apache-airflow-provider
英文:
I am trying to install a airflow provider in my virtual environment.
pip install apache-airflow-providers-mysql
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> [24 lines of output]
/bin/sh: 1: pkg-config: not found
/bin/sh: 1: pkg-config: not found
Trying pkg-config --exists mysqlclient
Command 'pkg-config --exists mysqlclient' returned non-zero exit status 127.
Trying pkg-config --exists mariadb
Command 'pkg-config --exists mariadb' returned non-zero exit status 127.
Traceback (most recent call last):
File "/home/user/airflow/airflow_env/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module>
main()
File "/home/user/airflow/airflow_env/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/home/user/airflow/airflow_env/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 118, in get_requires_for_build_wheel
return hook(config_settings)
File "/tmp/pip-build-env-a5nk1xf1/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 341, in get_requires_for_build_wheel
return self._get_build_requires(config_settings, requirements=['wheel'])
File "/tmp/pip-build-env-a5nk1xf1/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 323, in _get_build_requires
self.run_setup()
File "/tmp/pip-build-env-a5nk1xf1/overlay/lib/python3.10/site-packages/setuptools/build_meta.py", line 338, in run_setup
exec(code, locals())
File "<string>", line 154, in <module>
File "<string>", line 48, in get_config_posix
File "<string>", line 27, in find_package_name
Exception: Can not find valid pkg-config name.
Specify MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS env vars manually
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.
Expecting to see the mysql provider in the airflow connection drop down.
Tried options provided in https://stackoverflow.com/questions/66441854/cannot-install-apache-airflow-providers-mysql-1-0-0-and-apache-airflow-provider
答案1
得分: 3
指定MYSQLCLIENT_CFLAGS和MYSQLCLIENT_LDFLAGS环境变量,按照以下步骤进行:
-
打开一个终端窗口。
-
确定MySQL头文件和库文件的位置。这些位置可能因你的MySQL安装而异。你可以使用
mysql_config
命令获取这些信息。
运行以下命令查找头文件的位置:mysql_config --cflags
运行以下命令查找库文件的位置:mysql_config --libs
记下这些命令的输出,因为你在接下来的步骤中会用到它们。 -
设置MYSQLCLIENT_CFLAGS环境变量。用从
mysql_config --cflags
命令中获取的路径替代``。运行以下命令:export MYSQLCLIENT_CFLAGS="-I"
-
设置MYSQLCLIENT_LDFLAGS环境变量。用从
mysql_config --libs
命令中获取的路径替代``。
运行以下命令:export MYSQLCLIENT_LDFLAGS="-L"
注意:如果你的MySQL安装包含多个库,用空格分隔每个库路径。 -
现在,当你安装需要MySQL客户端库的软件包时,比如Django的
mysqlclient
,构建过程将使用指定的CFLAGS和LDFLAGS值来定位所需的文件。你可以继续进行软件包安装或Django设置,指定的环境变量将用于定位MySQL客户端库。
通过手动设置MYSQLCLIENT_CFLAGS和MYSQLCLIENT_LDFLAGS环境变量,你可以确保在安装或编译过程中使用正确的MySQL头文件和库文件。
我也用这种方法解决了和你一样的问题。
英文:
specify the MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS environment variables manually, follow the steps below:
-
Open a terminal window.
-
Determine the location of the MySQL header files and libraries. These locations may vary depending on your MySQL installation. You can use the
mysql_config
command to retrieve this information.
Run the following command to find the location of the header files:mysql_config --cflags
Run the following command to find the location of the libraries:mysql_config --libs
Note down the output of these commands, as you will need them in the next steps. -
Set the MYSQLCLIENT_CFLAGS environment variable. Replace `` with the path you obtained from the
mysql_config --cflags
command. Run the following command:export MYSQLCLIENT_CFLAGS="-I"
-
Set the MYSQLCLIENT_LDFLAGS environment variable. Replace `` with the path you obtained from the
mysql_config --libs
command.
Run the following command:export MYSQLCLIENT_LDFLAGS="-L"
Note: If your MySQL installation includes multiple libraries, separate each library path with a space. -
Now, when you install packages that require the MySQL client library, such as
mysqlclient
for Django, the build process will use the specified CFLAGS and LDFLAGS values to locate the necessary files. You can proceed with your package installation or Django setup, and the specified environment variables will be used to locate the MySQL client libraries.
By manually setting the MYSQLCLIENT_CFLAGS and MYSQLCLIENT_LDFLAGS environment variables, you can ensure that the correct MySQL header files and libraries are used during the installation or compilation process.
I solved the same problem as you using this method
答案2
得分: 2
我的电脑是MacBook,
brew install mysql
可以解决这个问题。
英文:
My pc is macbook,
brew install mysql
can solve it
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论