0
$\begingroup$

Rosanswers logo

Hello,

I am using VSCode as IDE for my ROS projects. Everything works well, but when I try to import rospkg, VSCode underlines it with a yellow line and shows warning message: "Import "rospkg" could not be resolved". When I try to run node with this import, rospkg works fine, so problem is only with syntax in VSCode.

Do you know how to solve it?


Originally posted by Ivan4815162342 on ROS Answers with karma: 5 on 2021-08-25

Post score: 0


Original comments

Comment by Ranjit Kathiriya on 2021-08-25:
Hello @Ivan4815162342,

This is a duplicated question of : #q382798, #q256565

I am closing this question. If you think that you couldn't find a solution feel free to re-open this.

Comment by Ivan4815162342 on 2021-08-25:
I have the paths mentioned in the first link, but that doesn't help. The second link is about the C++ library that is not my case. I should also say that other python imports like rospy, roslaunch, rosnode are not underlined.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Hello @Ivan4815162342,

I think that you have not updated the python interpreter path in VS code.

When I try to run node with this import, rospkg works fine.

In your terminal, you have to type which python then you will get the path of your interpreter.

Now, press Ctrl+Shift+P in VS code and click on Select Interpreter. Try to set the path that you got from your terminal as a python path. I think it will work and solve your problem.

If you are facing issue or any problem feel free to drop commet. I hope it helps!


Originally posted by Ranjit Kathiriya with karma: 1622 on 2021-08-25

This answer was ACCEPTED on the original site

Post score: 4


Original comments

Comment by Ivan4815162342 on 2021-08-25:
This works, thank you!

$\endgroup$

Your Answer

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