0
$\begingroup$

Rosanswers logo

The env I am using is ROS Noetic and VS Code along with Pylance.

  1. launching rospy nodes is working fine
  2. importing rospy gives a squiggle error in VSCode.
  3. Also, python syntax is not being highlighted properly. Along with that, I am also not getting auto-complete options.

I think it should be a configuration issue, but I don't know where and what I have to configure to resolve this. Any help would be appreciated.


Originally posted by krushnal on ROS Answers with karma: 5 on 2021-07-19

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Hello there,

You have to add 2 python paths into your settings.json file into VS Code.

These are the paths: The first path is for all packages of your local workspace and the second is for the global package.

{
    "python.autoComplete.extraPaths": [
        "/home/<pc-name>/<ws-name>/devel/lib/python3/dist-packages",
        "/opt/ros/noetic/lib/python3/dist-packages"
    ]
}

If you are using CPP then you have to add the path in the c_cpp_properties.json file.

The location of setting and c_cpp_properties JSON files will be :

 "~/<work-space>/devel/include"

Just to note for Pycharm Users: if you are using Pycharm then give this both paths by following these steps:

  1. Go to settings.
  2. Project: src > Project Structure > On the right-hand side click on + Add Content Root and locate both paths.

Try this you will be able to solve your problem and if you have any issues feel free to drop a comment.


Originally posted by Ranjit Kathiriya with karma: 1622 on 2021-07-19

This answer was ACCEPTED on the original site

Post score: 6


Original comments

Comment by krushnal on 2021-07-19:
thanks a lot .... that solves it!!!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.