Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python3 can't import tf #293

Closed
Acmece opened this issue Apr 22, 2018 · 6 comments
Closed

python3 can't import tf #293

Acmece opened this issue Apr 22, 2018 · 6 comments

Comments

@Acmece
Copy link

Acmece commented Apr 22, 2018

Refer to #259
Follow by @randoms , I start from scratch

mkdir catkin_ws
cd catkin_ws
mkdir src
cd src 
git clone https://github.com/ros/geometry
git clone https://github.com/ros/geometry2
cd ..
virtualenv -p /usr/bin/python3 venv
source venv/bin/activate
pip install catkin_pkg pyyaml empy rospkg numpy
catkin_make
source devel/setup.bash

However:
1) It clones from melodic-devel and I ran into some build errors:

[ 75%] [ 77%] [ 79%] Building CXX object geometry2/tf2/CMakeFiles/tf2.dir/src/cache.cpp.o
Building CXX object geometry2/tf2/CMakeFiles/tf2.dir/src/buffer_core.cpp.o
Building CXX object geometry2/tf2/CMakeFiles/tf2.dir/src/static_cache.cpp.o
/home/acmece/test/src/geometry2/tf2/src/buffer_core.cpp: In member function ‘bool tf2::BufferCore::warnFrameId(const char*, const string&) const’:
/home/acmece/test/src/geometry2/tf2/src/buffer_core.cpp:126:49: error: ‘CONSOLE_BRIDGE_logWarn’ was not declared in this scope
     CONSOLE_BRIDGE_logWarn("%s",ss.str().c_str());
........
.......
make[2]: *** [geometry2/tf2/CMakeFiles/tf2.dir/src/buffer_core.cpp.o] Error 1
make[1]: *** [geometry2/tf2/CMakeFiles/tf2.dir/all] Error 2
make: *** [all] Error 2
Invoking "make -j4 -l4" failed

(actually, I change to clone indigo-devel and it can be successfully built)

2) Alough I built indigo-devel and set up an python3 virtual environment, I still cannot import tf with python3

-- Found PythonInterp: /home/acmece/catkin_ws/venv/bin/python (found version "3.4.3") 
-- Using PYTHON_EXECUTABLE: /home/acmece/catkin_ws/venv/bin/python
......
......
-- +++ processing catkin package: 'tf2_py'
-- ==> add_subdirectory(geometry2/tf2_py)
-- Using these message generators: gencpp;genlisp;genpy
-- Found PythonLibs: /usr/lib/x86_64-linux-gnu/libpython2.7.so (found suitable version "2.7.6", minimum required is "2") 

It seem that I have to use /opt/ros/indigo/lib/python2.7 as long as I source /opt/ros/indigo/setup.bash in order to use catkin_make

I am a freshman of this feild. Any help will be greatly appreciated.

@Acmece Acmece closed this as completed Apr 23, 2018
@Acmece Acmece reopened this Apr 23, 2018
@Acmece Acmece changed the title catkin_make error: buffer_core ‘CONSOLE_BRIDGE_logWarn’ not declared python3 can't import tf Apr 23, 2018
@mikaelarguedas
Copy link
Member

this looks very similar to #259 (comment)
did you try installing python3-dev ?

@Acmece
Copy link
Author

Acmece commented Apr 24, 2018

@mikaelarguedas I did have installed python3-dev.

>>> import sys
>>> sys.path
['', '/opt/ros/indigo/lib/python2.7/dist-packages',
 '/home/acmece/catkin_ws/venv/lib/python3.4', 
'/home/acmece/catkin_ws/venv/lib/python3.4/plat-x86_64-linux-gnu', 
'/home/acmece/catkin_ws/venv/lib/python3.4/lib-dynload', 
'/usr/lib/python3.4', 
'/usr/lib/python3.4/plat-x86_64-linux-gnu', 
 '/home/acmece/catkin_ws/venv/lib/python3.4/site-packages']

I don't know how to delet this path '/opt/ros/indigo/lib/python2.7/dist-packages'
You know, if I didn't source /opt/ros/indigo/setup.bash, I can't use catkin_make commond.

@tfoote
Copy link
Member

tfoote commented Apr 24, 2018

You know, if I didn't source /opt/ros/indigo/setup.bash, I can't use catkin_make commond.

If you're creating a python 3 environment you cannot use the system installed versions of any of the python tools including catkin_make you must use a version from inside your workspace. See http://wiki.ros.org/Installation/Source for an example of how to invoke catkin_make_isolated with the path to the version inside your workspace.

@tfoote tfoote closed this as completed Apr 26, 2018
@tfoote
Copy link
Member

tfoote commented Apr 26, 2018

If you need more help getting this going. Please ask a question on answers.ros.org and make sure to link here as well as describing your question in full.

@whitecoffee
Copy link

I get the same problem as you, have u resolved it yet?

@tfoote
Copy link
Member

tfoote commented Jun 18, 2018

@whitecoffee you cannot mix python2 and python3. If you need more help please ask a question on answers.ros.org with full instructions how to reproduce your problem.

seanyen pushed a commit to ms-iot/geometry2 that referenced this issue Mar 22, 2021
Signed-off-by: Michael Carroll <michael@openrobotics.org>
lilustga pushed a commit to ms-iot/geometry2 that referenced this issue Sep 14, 2021
…e'd resources ros#386 (ros#419)

* fix accessing freed resources (ros#386)

* Avoid using invalid std::list iterators (ros#293)

Signed-off-by: Michael Carroll <michael@openrobotics.org>

Co-authored-by: Kazunari Tanaka <tzskp1@gmail.com>
Co-authored-by: Michael Carroll <michael@openrobotics.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants