检查和构建时柯南包管理器出现问题

Problem with conan package manager while inspect and build

以下 conan cmd 因语法无效而失败,但该文件不是我创建的。 不确定为什么会出现以下错误。

$ conan inspect poco/1.9.4
poco/1.9.4: Not found in local cache, looking in remotes...
poco/1.9.4: Trying with 'conancenter'...
Downloading conanmanifest.txt completed [0.74k]
Downloading conanfile.py completed [14.36k]
Downloading conan_export.tgz completed [0.30k]
Decompressing conan_export.tgz completed [0.00k]
poco/1.9.4: Downloaded recipe revision 0
ERROR: Error loading conanfile at '/home/snandi/.conan/data/poco/1.9.4/_/_/export/conanfile.py': Unable to load conanfile in /home/snandi/.conan/data/poco/1.9.4/_/_/export/conanfile.py
  File "/home/snandi/.conan/data/poco/1.9.4/_/_/export/conanfile.py", line 97
    tools.get(**self.conan_data["sources"][self.version],
                                                        ^
SyntaxError: invalid syntax

您的错误发生是因为 Python 2 无法解析 **self.conan_data 由于 Python 3.5 (PEP 448) 上引入的解包功能改进,您必须使用 Python 仅 3 个。

你可以简单地验证它 运行:

$ python2
Python 2.7.18 (default, Mar 24 2021, 14:28:23) 
[GCC 10.2.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> dict(**{'x': 1}, y=2, **{'z': 3})
  File "<stdin>", line 1
    dict(**{'x': 1}, y=2, **{'z': 3})
                   ^
SyntaxError: invalid syntax
$ python3
Python 3.9.6 (default, Jun 30 2021, 10:22:16) 
[GCC 11.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> dict(**{'x': 1}, y=2, **{'z': 3})
{'x': 1, 'y': 2, 'z': 3}

因此,解决您的问题:

首先,从 python2 卸载柯南:python2 -m pip uninstall conan

然后,只保留安装的 python 3 版本:python3 -m pip install -U conan

如果您在主机中管理 Python 环境有些困难,我建议您使用 pyenv,它管理安装的全球版本。