fzi-forschungszentrum-informatik / Lanelet2

Map handling framework for automated driving
BSD 3-Clause "New" or "Revised" License
800 stars 327 forks source link

building for python3 #36

Closed amastrobera closed 5 years ago

amastrobera commented 5 years ago

Dear guys,

I tried following the instructions to make lanelet2 in Python3, so, inside your docker image the command :

catkin init
catkin config --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo -DPYTHON_VERSION=3.6
catkin build

yielded this error :

[build] Found '11' packages in 0.0 seconds.
[build] Updating package table.
Starting  >>> catkin_tools_prebuild                
_______________________________________________________________________________________
Errors     << catkin_tools_prebuild:cmake /home/developer/workspace/logs/catkin_tools_prebuild/build.cmake.000.log
ImportError: "from catkin_pkg.package import parse_package" failed: No module named 'catkin_pkg'
Make sure that you have installed "catkin_pkg", it is up to date and on the PYTHONPATH.
CMake Error at /opt/ros/melodic/share/catkin/cmake/safe_execute_process.cmake:11 (message):
  execute_process(/usr/bin/python3.6
  "/opt/ros/melodic/share/catkin/cmake/parse_package_xml.py"
  "/opt/ros/melodic/share/catkin/cmake/../package.xml"
  "/home/developer/workspace/build/catkin_tools_prebuild/catkin/catkin_generated/version/package.cmake")
  returned error code 1
Call Stack (most recent call first):
  /opt/ros/melodic/share/catkin/cmake/catkin_package_xml.cmake:74 (safe_execute_process)
  /opt/ros/melodic/share/catkin/cmake/all.cmake:167 (_catkin_package_xml)
  /opt/ros/melodic/share/catkin/cmake/catkinConfig.cmake:20 (include)
  CMakeLists.txt:4 (find_package)

cd /home/developer/workspace/build/catkin_tools_prebuild; catkin build --get-env catkin_tools_prebuild | catkin env -si  /usr/bin/cmake /home/developer/workspace/build/catkin_tools_prebuild --no-warn-unus
ed-cli -DCATKIN_DEVEL_PREFIX=/home/developer/workspace/devel/.private/catkin_tools_prebuild -DCMAKE_INSTALL_PREFIX=/home/developer/workspace/install -DCMAKE_BUILD_TYPE=RelWithDebInfo -DPYTHON_VERSION=3.6;
 cd -
.......................................................................................
Failed     << catkin_tools_prebuild:cmake           [ Exited with code 1 ]
Failed    <<< catkin_tools_prebuild                 [ 1.3 seconds ]
Abandoned <<< mrt_cmake_modules                     [ Unrelated job failed ]
Abandoned <<< lanelet2_core                         [ Unrelated job failed ]
Abandoned <<< lanelet2_io                           [ Unrelated job failed ]
Abandoned <<< lanelet2_maps                         [ Unrelated job failed ]
Abandoned <<< lanelet2_projection                   [ Unrelated job failed ]
Abandoned <<< lanelet2_traffic_rules                [ Unrelated job failed ]
Abandoned <<< lanelet2_routing                      [ Unrelated job failed ]
Abandoned <<< lanelet2_python                       [ Unrelated job failed ]
Abandoned <<< lanelet2_examples                     [ Unrelated job failed ]
Abandoned <<< lanelet2_validation                   [ Unrelated job failed ]
[build] Summary: 0 of 11 packages succeeded.
[build]   Ignored:   1 packages were skipped or are blacklisted.
[build]   Warnings:  None.
[build]   Abandoned: 10 packages were abandoned.
[build]   Failed:    1 packages failed.
[build] Runtime: 1.3 seconds total.
amastrobera commented 5 years ago

I may have found a solution doing apt-get install python3-catkin-tools but still

The following packages have unmet dependencies:
 python-catkin-tools : Conflicts: python3-catkin-tools but 0.4.5-1 is to be installed
 python3-catkin-tools : Depends: python3-catkin-pkg (>= 0.2.9) but it is not going to be installed
                        Depends: python3-trollius but it is not installable
                        Conflicts: python-catkin-tools but 0.4.5-1 is to be installed

Apparently people talk about it here : https://github.com/ros-infrastructure/catkin_pkg/issues/125

poggenhans commented 5 years ago

The problem is on ROS side. They still use python2 for building their stuff. Installing catkin with python3 will uninstall your complete ROS installation because of conflicting files. To do this correctly on bionic and earlier, you would have to build ros from source with python3 as your default interpreter.

The "hacky" way to do this is to use python2 catkin for building while being in a python3-virtualenv and add the catkin package to your workspace. You might have to adapt your PYTHONPATH variable to make this work so that no python2 modules are mixed with python3 modules.

I'll close this because this is not related to Lanelet2. It is a general issue with ROS and catkin.

DavidLMonica commented 2 years ago

I have found a solution doing pip3 install catkin_pkg. If another error "No module named 'rospkg'" occured, try pip3 install rospkg.