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.
Parents
  • Hi Allen,

    The problem indeed seems to be that the nRF Connect Extension for VS code use "python", which for mac defaults to python 2.

    As a workaround, I was able to fix this by changing what python version "python" points to on the mac in general.
    Beware that this fix may change the behaviour of other applications using python on your computer.

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

    Our developers know about this issue, and it might be fixed in our extension in the future. Thank you for the report!

    Regards,
    Sigurd Hellesvik

  • Hi Siguard,

    Today I ran into the same problem Allen did. I have a brand new MacBook Pro with OS Monterey v12.0.1. Python2 and Python3 were already installed on the machine when I purchased it.  Running the command which python within a terminal window results in the following:

    % which python

    /usr/bin/python

    Using the ls -la command we can see /usr/bin/python is a link to python2.7

    % ls -la /usr/bin/python

    lrwxr-xr-x  1 root  wheel  75 Oct 17 20:30 /usr/bin/python -> ../../System/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7

    Using the which command and ls commands we can also see python3 is located in /usr/bin/python3 and that it’s not a link but the actual binary.

    % which python3

    /usr/bin/python3

    % ls -la /usr/bin/python3

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

    Because my versions of python are not located in the /usr/local/bin directory the command you suggested (i.e., ln -s -f /usr/local/bin/python3.7 /usr/local/bin/python) doesn’t work for me.  Instead I tried the command sudo ln -s -f /usr/bin/python3 /usr/bin/python. However, as you can see below I’m unable to successfully run this command.  

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

    ln: /usr/bin/python: Operation not permitted

    I tried remove the link /usr/bin/python with the command sudo rm /usr/bin/python but that wasn't allowed (see below).

    % sudo rm /usr/bin/python

    rm: /usr/bin/python: Operation not permitted 

    Is there another workaround so that nRF Connect Extension for VS uses python3?

    Regards,

    Peter

  • 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.

Reply Children
No Data
Related