Ask Your Question
1

error in import

asked 2014-10-15 06:02:59 -0600

Rahndall gravatar image

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

edit retag flag offensive close merge delete

Comments

Could it be related to the PYTHONPATH?

Rahndall gravatar imageRahndall ( 2014-10-15 07:29:42 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2014-10-29 04:54:14 -0600

Rahndall gravatar image

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

edit flag offensive delete link more
1

answered 2014-10-15 12:19:51 -0600

William gravatar image

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.

edit flag offensive delete link more

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: 2014-10-15 06:02:59 -0600

Seen: 578 times

Last updated: Oct 29 '14