specify mysqlclient cflags and mysqlclient ldflags env vars manually while pip install apache-airflow-providers-mysql | Windows | no docker

huangapple go评论112阅读模式
英文:

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

&#215; 获取构建轮子所需的要求未成功运行。
│ 退出代码:1
╰─&gt; 请查看上述输出。

期望在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

  &#215; Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─&gt; [24 lines of output]
      /bin/sh: 1: pkg-config: not found
      /bin/sh: 1: pkg-config: not found
      Trying pkg-config --exists mysqlclient
      Command &#39;pkg-config --exists mysqlclient&#39; returned non-zero exit status 127.
      Trying pkg-config --exists mariadb
      Command &#39;pkg-config --exists mariadb&#39; returned non-zero exit status 127.
      Traceback (most recent call last):
        File &quot;/home/user/airflow/airflow_env/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py&quot;, line 353, in &lt;module&gt;
          main()
        File &quot;/home/user/airflow/airflow_env/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py&quot;, line 335, in main
          json_out[&#39;return_val&#39;] = hook(**hook_input[&#39;kwargs&#39;])
        File &quot;/home/user/airflow/airflow_env/lib/python3.10/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py&quot;, line 118, in get_requires_for_build_wheel
          return hook(config_settings)
        File &quot;/tmp/pip-build-env-a5nk1xf1/overlay/lib/python3.10/site-packages/setuptools/build_meta.py&quot;, line 341, in get_requires_for_build_wheel
          return self._get_build_requires(config_settings, requirements=[&#39;wheel&#39;])
        File &quot;/tmp/pip-build-env-a5nk1xf1/overlay/lib/python3.10/site-packages/setuptools/build_meta.py&quot;, line 323, in _get_build_requires
          self.run_setup()
        File &quot;/tmp/pip-build-env-a5nk1xf1/overlay/lib/python3.10/site-packages/setuptools/build_meta.py&quot;, line 338, in run_setup
          exec(code, locals())
        File &quot;&lt;string&gt;&quot;, line 154, in &lt;module&gt;
        File &quot;&lt;string&gt;&quot;, line 48, in get_config_posix
        File &quot;&lt;string&gt;&quot;, 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

&#215; Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─&gt; 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环境变量,按照以下步骤进行:

  1. 打开一个终端窗口。

  2. 确定MySQL头文件和库文件的位置。这些位置可能因你的MySQL安装而异。你可以使用mysql_config命令获取这些信息。
    运行以下命令查找头文件的位置:mysql_config --cflags 运行以下命令查找库文件的位置:mysql_config --libs 记下这些命令的输出,因为你在接下来的步骤中会用到它们。

  3. 设置MYSQLCLIENT_CFLAGS环境变量。用从mysql_config --cflags命令中获取的路径替代``。运行以下命令:export MYSQLCLIENT_CFLAGS="-I"

  4. 设置MYSQLCLIENT_LDFLAGS环境变量。用从mysql_config --libs命令中获取的路径替代``。
    运行以下命令:export MYSQLCLIENT_LDFLAGS="-L" 注意:如果你的MySQL安装包含多个库,用空格分隔每个库路径。

  5. 现在,当你安装需要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:

  1. Open a terminal window.

  2. 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.

  3. 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=&quot;-I&quot;

  4. 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=&quot;-L&quot; Note: If your MySQL installation includes multiple libraries, separate each library path with a space.

  5. 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

huangapple
  • 本文由 发表于 2023年8月10日 19:52:05
  • 转载请务必保留本文链接:https://go.coder-hub.com/76875507.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定