-2
$\begingroup$

I am trying to follow a ros2 tutorial, and I have a test node working, it's an executable and runs as expected from the terminal. I am now trying to make the turtlesim node draw a circle. I have created draw_circle.py in the source directory of the workspace, in the same place that I have my_first_node.py. literally nothing is different. it then underlines rclpy in yellow on my python script and says it cant resolve import rclpy. These two nodes are in the same folder, same path and everything. I dont understand the difference! my_first_node that is running properly

draw_circle that cannot find rclpy

they are both executable in the ros2 directory

but the draw_circle node is not showing up as something I can run

I included the necessary line on package.xml

AND I have draw_circle in my setup.py I even tried to add a main function to draw_circle but that also didnt work. Both files are in the same directory so they are both using the same interpreter... Ive been working on this for many hours please someone help !!

$\endgroup$
4
  • 2
    $\begingroup$ please do not post pictures of text ... post the text instead ... format as code ... idownvotedbecau.se/imageofcode $\endgroup$
    – jsotola
    Feb 20 at 20:36
  • 1
    $\begingroup$ Please also include the actual error (as code formatted text), that you don't seem to have included a screenshot of. The error in the title appears to have been incorrectly written. $\endgroup$ Feb 20 at 22:10
  • 2
    $\begingroup$ I’m voting to close this question because the issue was caused by a typo. Such questions are unlikely to benefit other users. $\endgroup$ Feb 21 at 12:54
  • $\begingroup$ Please note, screenshots are not text-searchable, therefore that is why pasting the code as text is preferable. Please see Why are images of text, code and mathematical expressions discouraged? $\endgroup$ Feb 21 at 13:31

3 Answers 3

1
$\begingroup$

On your draw_circle.py file line 3 you have the code import rclypy which is an incorrect name of the module and the reason your are getting that error, just change that line to import rclpy and your code should work.

PD: Next time please follow the guidelines for asking questions so it is easier for anyone to understand your problem and help you. :)

$\endgroup$
1
$\begingroup$

Looks like you have a typo here.

Change rclypy to rclpy and see if it works.

$\endgroup$
1
  • 1
    $\begingroup$ Welcome to Robotics. Thanks for your answer but we are looking for comprehensive answers that provide some explanation and context. Very short answers cannot do this. See How to Answer for more info. $\endgroup$
    – Tully
    Feb 22 at 17:43
0
$\begingroup$

In addition to Diego's location of source of the error, there is another instance of the misspelling of rclypy in main(), at line 24 (in the second screenshot):

rclypy.init(args = args)

should be

rclpy.init(args = args)

However, the first screenshot, at line 20, (which is the same line in the same file?), the line doesn't contain the error, and is written correctly.

There may be others instances of this error, not shown in your (rather difficult to read) screenshots, so search the code and check all other instances of rclpy.

Please use code formatted text in future, instead of screenshots.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.