可以在Mac上使用PIP安装`roslz4`时找到`lz4`标头了

发布于 2025-02-07 09:34:02 字数 1136 浏览 0 评论 0原文

我正在尝试安装 roslz4 在我的Mac上,我会遇到以下错误。

      In file included from ros_comm/utilities/roslz4/src/_roslz4module.c:37:
      include/roslz4/lz4s.h:38:10: fatal error: 'lz4.h' file not found
      #include <lz4.h>
               ^~~~~~~
      1 error generated.
      error: command 'clang' failed with exit status 1
      [end of output]

为了解决这个问题,我将LZ4与Brew一起安装了,但是成功运行的

> brew install lz4
==> Downloading https://ghcr.io/v2/homebrew/core/lz4/manifests/1.9.3
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/lz4/blobs/sha256:d222923849a6fefd391ab6705f1468c10d287c08ab9c4b5053a18a552139e262
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:d222923849a6fefd391ab6705f1468c10d287c08ab9c4b5053a18a552139e262?se=2022-06-14T22%3A20%3A00Z&s
######################################################################## 100.0%
==> Pouring lz4--1.9.3.arm64_monterey.bottle.tar.gz

              

I'm trying to install roslz4 on my Mac, and I get the following error.

      In file included from ros_comm/utilities/roslz4/src/_roslz4module.c:37:
      include/roslz4/lz4s.h:38:10: fatal error: 'lz4.h' file not found
      #include <lz4.h>
               ^~~~~~~
      1 error generated.
      error: command 'clang' failed with exit status 1
      [end of output]

To counter this, I installed lz4 with brew which ran successfully

> brew install lz4
==> Downloading https://ghcr.io/v2/homebrew/core/lz4/manifests/1.9.3
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/lz4/blobs/sha256:d222923849a6fefd391ab6705f1468c10d287c08ab9c4b5053a18a552139e262
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:d222923849a6fefd391ab6705f1468c10d287c08ab9c4b5053a18a552139e262?se=2022-06-14T22%3A20%3A00Z&s
######################################################################## 100.0%
==> Pouring lz4--1.9.3.arm64_monterey.bottle.tar.gz
????  /opt/homebrew/Cellar/lz4/1.9.3: 22 files, 620.6KB
==> Running `brew cleanup lz4`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).

However, it does not appear to have resolved the problem.

Full pip output:

> pip install --extra-index-url https://rospypi.github.io/simple/ roslz4                
Looking in indexes: https://pypi.org/simple, https://rospypi.github.io/simple/
Collecting roslz4
  Using cached https://github.com/rospypi/simple/raw/any/roslz4/roslz4-1.14.3.post2.tar.gz (18 kB)
  Preparing metadata (setup.py) ... done
Building wheels for collected packages: roslz4
  Building wheel for roslz4 (setup.py) ... error
  error: subprocess-exited-with-error
  
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [21 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.macosx-10.14-arm64-3.8
      creating build/lib.macosx-10.14-arm64-3.8/roslz4
      copying ros_comm/utilities/roslz4/src/roslz4/__init__.py -> build/lib.macosx-10.14-arm64-3.8/roslz4
      running build_ext
      building '_roslz4' extension
      creating build/temp.macosx-10.14-arm64-3.8
      creating build/temp.macosx-10.14-arm64-3.8/ros_comm
      creating build/temp.macosx-10.14-arm64-3.8/ros_comm/utilities
      creating build/temp.macosx-10.14-arm64-3.8/ros_comm/utilities/roslz4
      creating build/temp.macosx-10.14-arm64-3.8/ros_comm/utilities/roslz4/src
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -DXXH_NAMESPACE=ROSLZ4_ -Iinclude -Iroscpp_core/cpp_common/include -I/Users/cmauceri/Workspace/run-mgmt/jupyter_venv/include -I/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8 -c ros_comm/utilities/roslz4/src/_roslz4module.c -o build/temp.macosx-10.14-arm64-3.8/ros_comm/utilities/roslz4/src/_roslz4module.o -Wno-strict-prototypes -Wno-missing-field-initializers -Wno-unused-variable -Wno-strict-aliasing
      In file included from ros_comm/utilities/roslz4/src/_roslz4module.c:37:
      include/roslz4/lz4s.h:38:10: fatal error: 'lz4.h' file not found
      #include <lz4.h>
               ^~~~~~~
      1 error generated.
      error: command 'clang' failed with exit status 1
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for roslz4
  Running setup.py clean for roslz4
Failed to build roslz4
Installing collected packages: roslz4
  Running setup.py install for roslz4 ... error
  error: subprocess-exited-with-error
  
  × Running setup.py install for roslz4 did not run successfully.
  │ exit code: 1
  ╰─> [21 lines of output]
      running install
      running build
      running build_py
      creating build
      creating build/lib.macosx-10.14-arm64-3.8
      creating build/lib.macosx-10.14-arm64-3.8/roslz4
      copying ros_comm/utilities/roslz4/src/roslz4/__init__.py -> build/lib.macosx-10.14-arm64-3.8/roslz4
      running build_ext
      building '_roslz4' extension
      creating build/temp.macosx-10.14-arm64-3.8
      creating build/temp.macosx-10.14-arm64-3.8/ros_comm
      creating build/temp.macosx-10.14-arm64-3.8/ros_comm/utilities
      creating build/temp.macosx-10.14-arm64-3.8/ros_comm/utilities/roslz4
      creating build/temp.macosx-10.14-arm64-3.8/ros_comm/utilities/roslz4/src
      clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -iwithsysroot/System/Library/Frameworks/System.framework/PrivateHeaders -iwithsysroot/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/Headers -arch arm64 -arch x86_64 -Werror=implicit-function-declaration -DXXH_NAMESPACE=ROSLZ4_ -Iinclude -Iroscpp_core/cpp_common/include -I/Users/cmauceri/Workspace/run-mgmt/jupyter_venv/include -I/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/include/python3.8 -c ros_comm/utilities/roslz4/src/_roslz4module.c -o build/temp.macosx-10.14-arm64-3.8/ros_comm/utilities/roslz4/src/_roslz4module.o -Wno-strict-prototypes -Wno-missing-field-initializers -Wno-unused-variable -Wno-strict-aliasing
      In file included from ros_comm/utilities/roslz4/src/_roslz4module.c:37:
      include/roslz4/lz4s.h:38:10: fatal error: 'lz4.h' file not found
      #include <lz4.h>
               ^~~~~~~
      1 error generated.
      error: command 'clang' failed with exit status 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.
╰─> roslz4

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

Do I need to add the location of lz4 headers to an environment variable? How can I get pip to find the header?

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

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

发布评论

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

评论(2

如何视而不见 2025-02-14 09:34:02

brew brew install lz4以下(来自 rgov )为我工作,而无需任何源代码更改:

CFLAGS="-I$(brew --prefix lz4)/include" \
LDFLAGS="-L$(brew --prefix lz4)/lib" \
pip install roslz4 --extra-index-url https://rospypi.github.io/simple/

After doing brew install lz4 the following (from this SO post by rgov) worked for me without the need of any source code changes:

CFLAGS="-I$(brew --prefix lz4)/include" \
LDFLAGS="-L$(brew --prefix lz4)/lib" \
pip install roslz4 --extra-index-url https://rospypi.github.io/simple/
她比我温柔 2025-02-14 09:34:02

同事的答案:

我的解决方案是下载roslz4 tarball,然后手动将Include文件夹和库符号添加到设置配置中,然后运行Python setup.py install.py install

这是我设置的前几行。补充和lib)

import platform
from setuptools import setup, Extension

extra_compile_args = []
include_dirs = [
    "include",
    "roscpp_core/cpp_common/include",
    "/usr/local/Cellar/lz4/1.9.3/include",
]
libraries = ["lz4"]
library_dirs = ["/usr/local/Cellar/lz4/1.9.3/lib"]
define_macros = [
    ("XXH_NAMESPACE", "ROSLZ4_"),
]

我的更改是带有“地窖”和“ library_dirs”的行

Answer from a coworker:

My solution was to download the roslz4 tarball and manually add the include folders and library symbols into the setup config, then run python setup.py install

Here are the first few lines of my setup.py file (which includes my addition to include and lib)

import platform
from setuptools import setup, Extension

extra_compile_args = []
include_dirs = [
    "include",
    "roscpp_core/cpp_common/include",
    "/usr/local/Cellar/lz4/1.9.3/include",
]
libraries = ["lz4"]
library_dirs = ["/usr/local/Cellar/lz4/1.9.3/lib"]
define_macros = [
    ("XXH_NAMESPACE", "ROSLZ4_"),
]

My changes are the lines with "Cellar" and "library_dirs"

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