Ask Your Question
0

Import "rospkg" could not be resolved

asked 2021-08-25 05:22:24 -0600

Ivan4815162342 gravatar image

updated 2021-08-25 06:14:29 -0600

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?

edit retag flag offensive close merge delete

Comments

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.

Ranjit Kathiriya gravatar image Ranjit Kathiriya  ( 2021-08-25 06:00:25 -0600 )edit

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.

Ivan4815162342 gravatar image Ivan4815162342  ( 2021-08-25 06:13:10 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
3

answered 2021-08-25 06:28:20 -0600

Ranjit Kathiriya gravatar image

updated 2021-08-25 06:29:42 -0600

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!

edit flag offensive delete link more

Comments

1

This works, thank you!

Ivan4815162342 gravatar image Ivan4815162342  ( 2021-08-25 06:35:19 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2021-08-25 05:22:24 -0600

Seen: 141 times

Last updated: Aug 25 '21