Search code examples
c++linuxwindows-subsystem-for-linuxconan

Problem with conan package manager while inspect and build


Below conan cmd failed with invalid syntax, but that file is not created by me. Not sure why below error is appearing.

$ 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

Solution

  • Your error occurs because Python 2 can not parse **self.conan_data due unpack feature improvement introduced on Python 3.5 (PEP 448), you have to use Python 3 only.

    You can validate it simply running:

    $ 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}
    

    Thus, to solve your problem:

    First, uninstall Conan from python2: python2 -m pip uninstall conan

    Then, keep only the python 3 version installed: python3 -m pip install -U conan

    If you have some difficult managing your Python environment in your host, I would suggest using pyenv, which manage the global version installed.