0
$\begingroup$

Rosanswers logo

Dear ROS-Users

I created a service in my_package but I am not able to import it. In particular, using "from my_package import srv" in a ros-python node raise me this error: ImportError: cannot import name srv

However, doing the same "from my_package import srv" from a python shell, I don't get any error

I'm using catkin on ros-hydro and both catkin_make and catkin_make install don't give me any erro

Thank you for your help


Originally posted by Rahndall on ROS Answers with karma: 133 on 2014-10-15

Post score: 1


Original comments

Comment by Rahndall on 2014-10-15:
Could it be related to the PYTHONPATH?

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

I would check the spelling in your python ROS node. If you can import it in a python shell and get the error by running the python node in the same terminal then I would guess it is a typo.

We would need more information in order to guess why this is happening, things like the python script (or part of it), the exact process you use when setting up your environment, your environment when before running the script, etc...

It could be related to your PYTHONPATH, you can print it with print(sys.path) right before you try the import in your python node and make sure the folder which contains the service code is in the path.


Originally posted by William with karma: 17335 on 2014-10-15

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$
0
$\begingroup$

Rosanswers logo

The problem was on the name of file: it gave me problem when package, file and node had the same name Sorry for the "noob" question


Originally posted by Rahndall with karma: 133 on 2014-10-29

This answer was ACCEPTED on the original site

Post score: 0

$\endgroup$

Your Answer

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