Import tensorflow in ROS kinetic
Hello everyone, I am having some troubles to use Tensorflow in ROS Kinetic. The error message is: (no error with catkin_make)
process[Filter-1]: started with pid [21302]
process[CallTensorflow-2]: started with pid [21303]
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/home/zoe/tensorflow-for-poets-2/scripts/label_image.py", line 25, in <module>
import tensorflow as tf
ImportError: No module named tensorflow
My python node is calling a .sh file which want to use and import tensorflow.
Tensorflow is installed on my computer as we can see:
Name: tensorflow
Version: 1.7.0
Summary: TensorFlow helps the tensors flow
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: opensource@google.com
License: Apache 2.0
Location: /usr/local/lib/python3.5/dist-packages
Requires: wheel, numpy, astor, protobuf, tensorboard, termcolor, gast, absl-py, grpcio, six
As tensorflow is installed in python 3.5 I can only import with python3 in the terminal
zoe@PC-ZOE:~$ python
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named tensorflow
zoe@PC-ZOE:~$ python3
>>> import tensorflow as tf
What I have already try:
- change the header of the python node to
#!/usr/bin/env python3
- add
source ~/tensorflow/bin/activate
at the beginning of my .sh file. - make
source ~/tensorflow/bin/activate
before roslaunch - add
<run_depend>python-tensorflow-pip</run_depend>
in the package.xml but I can't rosdep python-tensorflow-pip (as I see here https://answers.ros.org/question/2289... )
Can anyone help me, please? Thank you.
This seems to be a problem activating the TensorFlow environment. Are you able to use TensorFlow normally outside of ROS? Does your python node execute the shell script and then try and use TensorFlow? If so I'm not sure that would be expected to work.
Hi I am able to import tensorflow in python2 environment for ROS kinetic. I follow pip install method for python2 and nothing else.
Seems that your tensorflow has been installed on python3 only. Have you checked what version of python that actually run with your ROS?