安装 xmlsec 时,收到“错误:xmlsec1 未安装或路径不正确。”的提示。

10

我正在使用MacOS 10.15.7 Catalina操作系统,当前使用的是Python 3.8.4版本,并且已安装Pip 21.1.1。

但是无论什么原因,当我尝试运行python -m pip install xmlsec时,总是出现错误。

错误信息:

➜ python -m pip install xmlsec 
Collecting xmlsec
  Using cached xmlsec-1.3.10.tar.gz (62 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
    Preparing wheel metadata ... done
Requirement already satisfied: lxml>=3.8 in /Users/rsheikh/.pyenv/versions/3.8.4/lib/python3.8/site-packages (from xmlsec) (4.6.3)
Building wheels for collected packages: xmlsec
  Building wheel for xmlsec (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   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
       cwd: /private/var/folders/q6/l4q1yvg11v3dftcbdqr8jxgh0000gq/T/pip-install-re_pqhol/xmlsec_f862b9f5baae4fe49f2ba58dadb464f1
  Complete output (20 lines):
  running bdist_wheel
  running build
  running build_py
  /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
    warnings.warn(
  /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
    warnings.warn(
  /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
    warnings.warn(
  package init file 'src/xmlsec/__init__.py' not found (or not a regular file)
  creating build
  creating build/lib.macosx-10.15-x86_64-3.8
  creating build/lib.macosx-10.15-x86_64-3.8/xmlsec
  copying src/xmlsec/py.typed -> build/lib.macosx-10.15-x86_64-3.8/xmlsec
  copying src/xmlsec/tree.pyi -> build/lib.macosx-10.15-x86_64-3.8/xmlsec
  copying src/xmlsec/__init__.pyi -> build/lib.macosx-10.15-x86_64-3.8/xmlsec
  copying src/xmlsec/constants.pyi -> build/lib.macosx-10.15-x86_64-3.8/xmlsec
  copying src/xmlsec/template.pyi -> build/lib.macosx-10.15-x86_64-3.8/xmlsec
  running build_ext
  error: xmlsec1 is not installed or not in path.
  ----------------------------------------
  ERROR: Failed building wheel for xmlsec
Failed to build xmlsec
ERROR: Could not build wheels for xmlsec which use PEP 517 and cannot be installed directly

然而,我通过执行命令 xmlsec1 --version 进行验证,确认xmlsec1已安装,并返回: xmlsec1 1.2.32 (openssl)

目前为止,我已经使用homebrew安装了pkg-config 0.29.2_3Libxmlsec1 1.2.32libxml2 2.9.10_2

我还在./zshrc文件中添加了必要的Libxmlsec1输出和openssl 1.1输出。

是否需要添加其他参数到我的zsh路径中才能使pip安装操作正常运行?我有没有遗漏什么?


which xmlsec1 打印什么?你修改了 .zprofile.zshrc 或其他文件中的 PATH 吗? - SuperStormer
/usr/local/bin/xmlsec1 and I modified my .zshrc to include: export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include" export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig" export LDFLAGS="-L/usr/local/opt/libxml2/lib" export CPPFLAGS="-I/usr/local/opt/libxml2/include" export PKG_CONFIG_PATH="/usr/local/opt/libxml2/lib/pkgconfig"``` - Rachel Sheikh
但我不确定在.zshrc中添加什么到我的PATH,以使xmlsec1被识别。 - Rachel Sheikh
3个回答

7
错误很令人困惑,它似乎需要开发库。
sudo apt install libxmlsec1 libxmlsec1-dev

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


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的。

0

我在尝试将我的聊天机器人部署到Heroku时遇到了问题。以下是我解决问题的方法。希望能帮助正在查找解决方案的人!

错误消息表明xmlsec1未安装或未在路径中。您可以尝试通过以下步骤将xmlsec1添加为Heroku上的构建包:

  1. 在终端中,导航到您的项目目录。
  2. 运行以下命令将xmlsec1构建包添加到您的Heroku应用程序中: heroku buildpacks:add https://github.com/heroku/heroku-buildpack-apt.git
  3. 在项目的根目录中创建一个名为Aptfile的文件。将以下行添加到Aptfile中: libxml2-dev libxmlsec1-dev pkg-config
  4. 通过运行以下命令将Aptfile提交到您的git存储库并将更改推送到Heroku: git add Aptfile git commit -m "Add Aptfile for xmlsec1 buildpack" git push heroku main

这将在您的Heroku应用程序上安装xmlsec1及其依赖项,并允许成功完成构建。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接