ros / geometry2

A set of ROS packages for keeping track of coordinate transforms.
189 stars 275 forks source link

ModuleNotFoundError for tf2_py #472

Closed a-z-e-r-i-l-a closed 4 years ago

a-z-e-r-i-l-a commented 4 years ago

I have a script where a module that uses tf is imported in python3 and this works with no error. This import calls the/home/azerila/ws/src/pkgs_for_py3/geometry2/tf2_py/src/tf2_py/__init__.py in my workspace that is made with python3 cmake args.

In another line of the same script which uses multiprocessing module the same python file is called again under the hood however this time with error:

    import tf
  File "/opt/ros/melodic/lib/python2.7/dist-packages/tf/__init__.py", line 30, in <module>
    from tf2_ros import TransformException as Exception, ConnectivityException, LookupException, ExtrapolationException
  File "/home/azerila/ws/src/pkgs_for_py3/geometry2/tf2_ros/src/tf2_ros/__init__.py", line 38, in <module>
    from tf2_py import *
  File "/home/azerila/ws/src/pkgs_for_py3/geometry2/tf2_py/src/tf2_py/__init__.py", line 53, in <module>
    from ._tf2 import *
ModuleNotFoundError: No module named 'tf2_py._tf2'

But what happened to be different this time compared to the first time when it worked?

My first guess was that perhaps the PYTHONPATH has changed for the second time, but inside/tf2_py/__init__.pyI also print the os.environ["PYTHONPATH"] and os.environ["PATH"] but for both times they look the same so I don't understand why one time it can be imported but the second time the above ModuleNotFoundError.

Is there any other environmental variable that might be different between these two calls that I can print and check if it's because of that?

This thread seems quite related to my issue but still I didn't find a clue inside it for my case.

tfoote commented 4 years ago

This looks like a question about your usage.

Please ask questions on http://answers.ros.org according to our support policy: http://wiki.ros.org/Support We try to keep the issue tracker reserved for bugs and feature developments.

Make sure to provide enough details in your question to reproduce your problem. Without being able to reproduce your problem we can only guess at what isn't working.