python error in kconfig extension?

When loading the nRF Connect Plugin for VCS, I am receiving either a crash message or the message below. It looks like a Python syntax error in the kconfig extension. python should be pointing to python2 in the 1.7.0 SDK directory.

This is the output window

[Info - 3:08:26 PM] Connection to server got closed. Server will restart.
File "/Users/allencurtis/.vscode/extensions/nordic-semiconductor.nrf-kconfig-2021.11.7/srv/kconfiglsp.py", line 65
self.diags: Dict[str, List[Diagnostic]] = {}
^
SyntaxError: invalid syntax
File "/Users/allencurtis/.vscode/extensions/nordic-semiconductor.nrf-kconfig-2021.11.7/srv/kconfiglsp.py", line 65
self.diags: Dict[str, List[Diagnostic]] = {}
^
SyntaxError: invalid syntax
[Info - 3:08:26 PM] Connection to server got closed. Server will restart.
File "/Users/allencurtis/.vscode/extensions/nordic-semiconductor.nrf-kconfig-2021.11.7/srv/kconfiglsp.py", line 65
self.diags: Dict[str, List[Diagnostic]] = {}
^
SyntaxError: invalid syntax
[Info - 3:08:26 PM] Connection to server got closed. Server will restart.
File "/Users/allencurtis/.vscode/extensions/nordic-semiconductor.nrf-kconfig-2021.11.7/srv/kconfiglsp.py", line 65
self.diags: Dict[str, List[Diagnostic]] = {}
^
SyntaxError: invalid syntax
[Info - 3:08:26 PM] Connection to server got closed. Server will restart.
File "/Users/allencurtis/.vscode/extensions/nordic-semiconductor.nrf-kconfig-2021.11.7/srv/kconfiglsp.py", line 65
self.diags: Dict[str, List[Diagnostic]] = {}
^
SyntaxError: invalid syntax
[Error - 3:08:26 PM] Connection to server got closed. Server will not be restarted.
  • Hi Peter,

    Looks like you covered all the possibilities except for one. I might be that the extension is looking for python in /usr/local/bin/python. So if you do this: 

    ln -s -f /usr/local/bin/python3.9 /usr/local/bin/python

    It might work. It did for me. You might have to change the link to python3.9 depending on your installation. 

    Steve

  • Remember this is all dependent on the how your PATH is configured.

  • Hi Peter,

    As I understand it,your operating system will first look for Python at /usr/local/bin. If it does not find it there, it will use the one from /usr/bin.

    You are not allowed to remove or overwrite your programs installed at /usr/bin.

    So for this workaround I suggest you try to link python3 to /usr/local/bin:

    ln -s -f <path_to_python3> /usr/local/bin/python

    It could be a good idea to screenshot the contents of /usr/local/bin before you do this, so you can revert to what you had in case you break something.

    Regards,
    Sigurd Hellesvik

  • Hi Everyone,

    Thanks for all your suggestions. 

    Below I include a transcript of what I've done. Unfortunately I'm still not able to get things to work.

    Here I show I'm using the zsh shell on my MacBook Pro running OS Monterey v12.0.1.

    % echo $0

    -zsh

    Next I display the PATH variable.

    % echo $PATH

    /opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

    I confirmed there is no python file in /opt/homebrew/bin or /opt/homebrew/sbin.

     

    The location of python3 is /usr/bin/python3.

    % which python3

    /usr/bin/python3

    We see /usr/bin/python3 is not a link.  It's the actual binary.

    % ls -la /usr/bin/python3

    -rwxr-xr-x  1 root  wheel  137696 Oct 17 20:30 /usr/bin/python3

     

    Point /usr/local/bin/python to /usr/bin/python3.

    % sudo ln -s -f /usr/bin/python3 /usr/local/bin/python

    Open a new terminal window and confirm the link is correct.

    % ls -la /usr/local/bin/python

    lrwxr-xr-x  1 root  wheel  16 Nov  9 09:30 /usr/local/bin/python -> /usr/bin/python3

    Confirm OS uses PATH to find python in /usr/local/bin/.

    % which python

    /usr/local/bin/python

    But when I run python -V I'm still getting v2.7.

    % python -V

    Python 2.7.18

    And when I start python from the command line I'm still getting v 2.7.

    % python

    WARNING: Python 2.7 is not recommended. 

    This version is included in macOS for compatibility with legacy software. 

    Future versions of macOS will not include Python 2.7. 

    Instead, it is recommended that you transition to using 'python3' from within Terminal.

    Python 2.7.18 (default, Oct  2 2021, 04:20:38) 

    [GCC Apple LLVM 13.0.0 (clang-1300.0.29.1) [+internal-os, ptrauth-isa=deploymen on darwin

    Type "help", "copyright", "credits" or "license" for more information.

    >>>

    And when I run /usr/local/bin/python -V I get v2.7.

    % /usr/local/bin/python -V

    Python 2.7.18

    But when I run /usr/bin/python3 -V I get v3.8.

    % /usr/bin/python3 -V

    Python 3.8.9

     

    I'm not sure what is going on.

     

  • Peter,

    You can not replace an executable with a symbolic link. You can use force to change a symbolic link to point else ware. It appears that /usr/local/bin/python is the v2.7 executable, not a link to the executable.

    Here is a thought. python3 is contained in the SDK installation under toolchain/bin. "python" does not exist in that directory. Change your path so /opt/nordic/ncs/v1.7.1/toolchain/bin is first. Create a python symbolic link here to python3 in that directory.

Related