当 pip 安装 xmlsec 时,收到“错误:xmlsec1 未安装或不在路径中。”

Rac*_*ikh 14 python macos homebrew pip xmlsec1

我使用的是 MacOS 10.15.7 Catalina,目前使用的是 Python 3.8.4 和 Pip 21.1.1

\n

无论出于何种原因,当我尝试运行时,我不断收到错误python -m pip install xmlsec

\n

文本形式错误:

\n
\xe2\x9e\x9c python -m pip install xmlsec \nCollecting xmlsec\n  Using cached xmlsec-1.3.10.tar.gz (62 kB)\n  Installing build dependencies ... done\n  Getting requirements to build wheel ... done\n  Installing backend dependencies ... done\n    Preparing wheel metadata ... done\nRequirement already satisfied: lxml>=3.8 in /Users/rsheikh/.pyenv/versions/3.8.4/lib/python3.8/site-packages (from xmlsec) (4.6.3)\nBuilding wheels for collected packages: xmlsec\n  Building wheel for xmlsec (PEP 517) ... error\n  ERROR: Command errored out with exit status 1:\n   command: /Users/rsheikh/.pyenv/versions/3.8.4/bin/python /Users/rsheikh/.pyenv/versions/3.8.4/lib/python3.8/site-packages/pip/_vendor/pep517/in_process/_in_process.py build_wheel /var/folders/q6/l4q1yvg11v3dftcbdqr8jxgh0000gq/T/tmp6b9bs29g\n       cwd: /private/var/folders/q6/l4q1yvg11v3dftcbdqr8jxgh0000gq/T/pip-install-re_pqhol/xmlsec_f862b9f5baae4fe49f2ba58dadb464f1\n  Complete output (20 lines):\n  running bdist_wheel\n  running build\n  running build_py\n  /private/var/folders/q6/l4q1yvg11v3dftcbdqr8jxgh0000gq/T/pip-build-env-dqtkuueu/overlay/lib/python3.8/site-packages/setuptools/dist.py:648: UserWarning: Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead\n    warnings.warn(\n  /private/var/folders/q6/l4q1yvg11v3dftcbdqr8jxgh0000gq/T/pip-build-env-dqtkuueu/overlay/lib/python3.8/site-packages/setuptools/dist.py:648: UserWarning: Usage of dash-separated 'build-requires' will not be supported in future versions. Please use the underscore name 'build_requires' instead\n    warnings.warn(\n  /private/var/folders/q6/l4q1yvg11v3dftcbdqr8jxgh0000gq/T/pip-build-env-dqtkuueu/overlay/lib/python3.8/site-packages/setuptools/dist.py:648: UserWarning: Usage of dash-separated 'upload-dir' will not be supported in future versions. Please use the underscore name 'upload_dir' instead\n    warnings.warn(\n  package init file 'src/xmlsec/__init__.py' not found (or not a regular file)\n  creating build\n  creating build/lib.macosx-10.15-x86_64-3.8\n  creating build/lib.macosx-10.15-x86_64-3.8/xmlsec\n  copying src/xmlsec/py.typed -> build/lib.macosx-10.15-x86_64-3.8/xmlsec\n  copying src/xmlsec/tree.pyi -> build/lib.macosx-10.15-x86_64-3.8/xmlsec\n  copying src/xmlsec/__init__.pyi -> build/lib.macosx-10.15-x86_64-3.8/xmlsec\n  copying src/xmlsec/constants.pyi -> build/lib.macosx-10.15-x86_64-3.8/xmlsec\n  copying src/xmlsec/template.pyi -> build/lib.macosx-10.15-x86_64-3.8/xmlsec\n  running build_ext\n  error: xmlsec1 is not installed or not in path.\n  ----------------------------------------\n  ERROR: Failed building wheel for xmlsec\nFailed to build xmlsec\nERROR: Could not build wheels for xmlsec which use PEP 517 and cannot be installed directly\n
Run Code Online (Sandbox Code Playgroud)\n

但是,我验证了 xmlsec1 是随 一起安装的xmlsec1 --version,它返回:xmlsec1 1.2.32 (openssl)

\n

到目前为止,我用自制软件安装了pkg-config 0.29.2_3Libxmlsec1 1.2.32、 和libxml2 2.9.10_2

\n

我还添加了必要的Libxmlsec1导出和openssl 1.1导出到我的./zshrc.

\n

我是否需要添加一个额外的参数到我的 zsh 路径中,以使这个 pip 安装正常工作,但我缺少这个参数?

\n

ozm*_*zma 10

该错误令人困惑。似乎需要开发库

sudo apt install libxmlsec1 libxmlsec1-dev
Run Code Online (Sandbox Code Playgroud)

(如果仍然失败,请尝试 Almenon 的答案)


Alm*_*non 1

我在 Ubuntu 上遇到了同样的问题。我认为问题是使用了brew 的pkg-config 而不是我通过apt 安装的pkg-config。要修复它,请将 PKG_CONFIG_PATH 更改为指向 apt pkg-config。

对我来说,它是下面的命令,但如果你在 Mac 上,它可能会有所不同。

export PKG_CONFIG_PATH=/usr/local/lib/x86_64-linux-gnu/pkgconfig:/usr/local/lib/pkgconfig:/usr/local/share/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig

然后运行 ​​pip install 并享受。

也不确定它是否有什么不同,但我通过 apt 安装了 Libxmlsec1。