ethz-asl / vgn

Real-time 6 DOF grasp detection in clutter.
BSD 3-Clause "New" or "Revised" License
257 stars 55 forks source link

python3 ImportError: dynamic module does not define module export function (PyInit__tf2) #5

Closed zhengshuai1 closed 3 years ago

zhengshuai1 commented 3 years ago

Hi, My hardware environment is: ubuntu 18.04 and ros melodic, python 3 virtual environment. When I run the robot grasping: python scripts/panda_grasp.py --model data/models/vgn_conv.pth the error is: Traceback (most recent call last): File "scripts/panda_grasp.py", line 17, in from vgn import vis File "/home/hp/graspdemo_ws/src/vgn/src/vgn/vis.py", line 10, in from vgn.utils import ros_utils, workspace_lines File "/home/hp/graspdemo_ws/src/vgn/src/vgn/utils/ros_utils.py", line 6, in import tf2_ros File "/opt/ros/melodic/lib/python2.7/dist-packages/tf2_ros/init.py", line 38, in from tf2_py import File "/opt/ros/melodic/lib/python2.7/dist-packages/tf2_py/init.py", line 38, in from ._tf2 import ImportError: dynamic module does not define module export function (PyInit__tf2)

I search this error on the website, it shows that I should use python2 rather than python3 to run this .py script. However, when I use python2 I can't use pip to install the black module in the requirements. How could I solve this problem?

maxsvetlik commented 3 years ago

Am experiencing this same thing (18.04, Python 2.7 base, running this VGN in a Python 3.6 virtual environment). I didn't want to migrate to Noetic, in which the above error wouldn't come up because MoveIt and its dependent ROS packages would all be compiled against Python 3 (resolving the issue the error is complaining about)

My workaround has been this: comment out the vis lines that are problematic, as well as moveit_commander in panda_control.py and port the code in panda_control.py that uses moveit_commander directly to using the topics that MoveIt exposes, namely the /move_group/goal action. This obviously isn't ideal if you need visualization, but as far as robot control it's equivalent.

My real suggestion would be to run vgn in a docker container that is running 20.04 / Noetic; this would have been my first preference but doesn't exactly solve all my issues, thus I went with the above workaround.

mbreyer commented 3 years ago

Hi, the issue is that I upgraded my system to Ubuntu 20.04 for python3 support, but I realize now that some dependencies are just not ready for ROS noetic yet. I'll have a look at making the package compatible with both python versions :slightly_smiling_face:

fatPeter commented 2 years ago

A pausible solution for me. https://blog.csdn.net/jiesunliu3215/article/details/124365080