MATLAB Answers

Error using ros.ros2.i​nternal.cr​eateOrGetL​ocalPython

50 views (last 30 days)
Hello,
Recently I encountered the following error when trying to call ros2genmsg. Anyone can help? Thanks in advance.
Error using ros.ros2.internal.createOrGetLocalPython (line 133)
Could not install the required Python packages: Looking in links:
/var/home/alex/opt/MATLAB/R2020a/sys/ros2/share/python
Processing /var/home/alex/opt/MATLAB/R2020a/sys/ros2/share/python/argcomplete-1.10.0-py2.py3-none-any.whl
Processing /var/home/alex/opt/MATLAB/R2020a/sys/ros2/share/python/flake8-3.7.8-py2.py3-none-any.whl
Processing /var/home/alex/opt/MATLAB/R2020a/sys/ros2/share/python/flake8-blind-except-0.1.1.tar.gz
Processing /var/home/alex/opt/MATLAB/R2020a/sys/ros2/share/python/flake8_class_newline-1.6.0-py3-none-any.whl
Processing /var/home/alex/opt/MATLAB/R2020a/sys/ros2/share/python/flake8_comprehensions-2.1.0-py3-none-any.whl
Processing /var/home/alex/opt/MATLAB/R2020a/sys/ros2/share/python/flake8_docstrings-1.3.0-py2.py3-none-any.whl
Processing /var/home/alex/opt/MATLAB/R2020a/sys/ros2/share/python/flake8_import_order-0.18.1-py2.py3-none-any.whl
Processing /var/home/alex/opt/MATLAB/R2020a/sys/ros2/share/python/flake8-quotes-2.0.1.tar.gz
Processing /var/home/alex/opt/MATLAB/R2020a/sys/ros2/share/python/pytest-5.0.1-py3-none-any.whl
Processing /var/home/alex/opt/MATLAB/R2020a/sys/ros2/share/python/pytest_cov-2.7.1-py2.py3-none-any.whl
Processing /var/home/alex/opt/MATLAB/R2020a/sys/ros2/share/python/pytest_runner-5.1-py2.py3-none-any.whl
Processing /var/home/alex/opt/MATLAB/R2020a/sys/ros2/share/python/pytest_repeat-0.8.0-py2.py3-none-any.whl
Processing /var/home/alex/opt/MATLAB/R2020a/sys/ros2/share/python/pytest_rerunfailures-7.0-py2.py3-none-any.whl
Processing /var/home/alex/opt/MATLAB/R2020a/sys/ros2/share/python/colcon_common_extensions-0.2.0-py3-none-any.whl
Processing /var/home/alex/opt/MATLAB/R2020a/sys/ros2/share/python/lark-parser-0.7.2.tar.gz
[31mERROR: Could not find a version that satisfies the requirement numpy (from versions: none)[0m
[31mERROR: No matching distribution found for numpy[0m
. Verify there is space on disk to create the packages and retry the command.
Error in ros2genmsg (line 53)
ros.ros2.internal.createOrGetLocalPython(); %ensure python is available
For reference,
>> pyenv
ans =
PythonEnvironment with properties:
Version: "3.8"
Executable: "/var/home/alex/miniconda3/envs/matlab/bin/python"
Library: "/var/home/alex/miniconda3/envs/matlab/lib/libpython3.8.so"
Home: "/var/home/alex/miniconda3/envs/matlab"
Status: NotLoaded
ExecutionMode: InProcess

  0 Comments

Sign in to comment.

Accepted Answer

Cam Salzberger
Cam Salzberger on 27 Jul 2020
Hello Alexander,
There is unfortunately an issue with the current documentation, which should be updated soon. Instead of Python 3.7+, you need exactly Python 3.7 to use ROS 2 custom messages or code generation with MATLAB. Once you install Python 3.7 and point MATLAB to use it with pyenv('Version', <executable path>), it should work.
-Cam

  11 Comments

Show 8 older comments
Cam Salzberger
Cam Salzberger on 28 Jul 2020
What OS and version are you using? I want to try to reproduce this if possible.
I have seen one other instance where having Python 3.8 available, while trying to use Python 3.7, is actually causing issues. The issues didn't look anything like this one, but it might be worth trying. Run this within MATLAB:
getenv('PATH')
and see if there is any mention of Python 3.8 in there. If so, try removing removing it and setting the environment variable to the new value without it. If you do this just within MATLAB, it won't affect your environment outside of it.
-Cam
Alexander Wang
Alexander Wang on 29 Jul 2020
I am running Fedora 32 Silverblue. Matlab is started within conda env, both python and python3, pip and pip3 have been redirected to python3.7. Though python3.8 does exist in /usr/bin/, unless there are scripts calling python3.8 explicitly, I guess it should not be a problem?
If I remove /usr/bin/ from PATH by setenv, lots of linux tools are missing. Besides, Fedora Silverblue has its root directory immutable, I cannot rename anything under /usr/.
for your reference, i uploaded the entire build log.
-- The C compiler identification is GNU 7.3.0
-- The CXX compiler identification is GNU 7.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /var/home/alex/miniconda3/envs/matlab/bin/x86_64-conda_cos6-linux-gnu-cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /var/home/alex/miniconda3/envs/matlab/bin/x86_64-conda_cos6-linux-gnu-c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found ament_cmake: 0.7.3 (/var/home/alex/opt/MATLAB/R2020a/sys/ros2/glnxa64/ros2/share/ament_cmake/cmake)
-- Found PythonInterp: /var/home/alex/.matlab/R2020a/ros2/python_venv/bin/python3 (found suitable version "3.7.7", minimum required is "3")
-- Using PYTHON_EXECUTABLE: /var/home/alex/.matlab/R2020a/ros2/python_venv/bin/python3
-- Found ament_cmake_ros: 0.7.0 (/var/home/alex/opt/MATLAB/R2020a/sys/ros2/glnxa64/ros2/share/ament_cmake_ros/cmake)
-- Found rosidl_typesupport_c: 0.7.1 (/var/home/alex/opt/MATLAB/R2020a/sys/ros2/glnxa64/ros2/share/rosidl_typesupport_c/cmake)
-- Found rosidl_typesupport_cpp: 0.7.1 (/var/home/alex/opt/MATLAB/R2020a/sys/ros2/glnxa64/ros2/share/rosidl_typesupport_cpp/cmake)
-- Found rosidl_default_generators: 0.7.0 (/var/home/alex/opt/MATLAB/R2020a/sys/ros2/glnxa64/ros2/share/rosidl_default_generators/cmake)
-- Found OpenSSL: /var/home/alex/miniconda3/envs/matlab/lib/libcrypto.so (found version "1.1.1g")
-- Found FastRTPS: /var/home/alex/opt/MATLAB/R2020a/sys/ros2/glnxa64/ros2/include
-- Found rosidl_adapter: 0.7.4 (/var/home/alex/opt/MATLAB/R2020a/sys/ros2/glnxa64/ros2/share/rosidl_adapter/cmake)
-- Found class_loader: 1.3.1 (/var/home/alex/opt/MATLAB/R2020a/sys/ros2/glnxa64/ros2/share/class_loader/cmake)
-- Found poco_vendor: (/var/home/alex/opt/MATLAB/R2020a/sys/ros2/glnxa64/ros2/share/poco_vendor/cmake)
-- Found rclcpp: 0.7.6 (/var/home/alex/opt/MATLAB/R2020a/sys/ros2/glnxa64/ros2/share/rclcpp/cmake)
-- Found rmw_implementation_cmake: 0.7.2 (/var/home/alex/opt/MATLAB/R2020a/sys/ros2/glnxa64/ros2/share/rmw_implementation_cmake/cmake)
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Found std_msgs: 0.7.0 (/var/home/alex/opt/MATLAB/R2020a/sys/ros2/glnxa64/ros2/share/std_msgs/cmake)
-- Found PythonInterp: /var/home/alex/.matlab/R2020a/ros2/python_venv/bin/python3 (found version "3.7.7")
-- Using all available rosidl_typesupport_c: rosidl_typesupport_fastrtps_c;rosidl_typesupport_introspection_c
-- Using all available rosidl_typesupport_cpp: rosidl_typesupport_fastrtps_cpp;rosidl_typesupport_introspection_cpp
-- Found PythonInterp: /var/home/alex/.matlab/R2020a/ros2/python_venv/bin/python3 (found suitable version "3.7.7", minimum required is "3.5")
-- Found python_cmake_module: 0.7.7 (/var/home/alex/opt/MATLAB/R2020a/sys/ros2/glnxa64/ros2/share/python_cmake_module/cmake)
-- Found PythonLibs: /var/home/alex/.matlab/R2020a/ros2/python_venv/lib/libpython3.7m.so (found suitable version "3.7.7", minimum required is "3.5")
-- Using PYTHON_EXECUTABLE: /var/home/alex/.matlab/R2020a/ros2/python_venv/bin/python3
-- Using PYTHON_INCLUDE_DIRS: /var/home/alex/.matlab/R2020a/ros2/python_venv/include/python3.7m
-- Using PYTHON_LIBRARIES: /var/home/alex/.matlab/R2020a/ros2/python_venv/lib/libpython3.7m.so
-- Found PythonExtra: .so
-- Configuring done
-- Generating done
-- Build files have been written to: /var/home/alex/devel/finger_perception/matlab_msg_gen/glnxa64/build/tactile_msgs
[35m[1mScanning dependencies of target tactile_msgs__cpp[0m
[ 2%] [34m[1mGenerating C code for ROS interfaces[0m
[ 5%] [34m[1mGenerating C++ code for ROS interfaces[0m
[ 5%] Built target tactile_msgs__cpp
[ 11%] [34m[1mGenerating C++ type support for eProsima Fast-RTPS[0m
[ 11%] [34m[1mGenerating C++ type support dispatch for ROS interfaces[0m
[ 14%] [34m[1mGenerating C++ introspection for ROS interfaces[0m
[35m[1mScanning dependencies of target tactile_msgs__rosidl_generator_c[0m
[ 17%] [32mBuilding C object CMakeFiles/tactile_msgs__rosidl_generator_c.dir/rosidl_generator_c/tactile_msgs/msg/tactile_signal__functions.c.o[0m
[ 20%] [32m[1mLinking C shared library libtactile_msgs__rosidl_generator_c.so[0m
[ 20%] Built target tactile_msgs__rosidl_generator_c
[ 25%] [34m[1mGenerating C type support dispatch for ROS interfaces[0m
[ 25%] [34m[1mGenerating C introspection for ROS interfaces[0m
[35m[1mScanning dependencies of target tactile_msgs__rosidl_typesupport_cpp[0m
[35m[1mScanning dependencies of target tactile_msgs__rosidl_typesupport_introspection_cpp[0m
[ 28%] [32mBuilding CXX object CMakeFiles/tactile_msgs__rosidl_typesupport_cpp.dir/rosidl_typesupport_cpp/tactile_msgs/msg/tactile_signal__type_support.cpp.o[0m
[35m[1mScanning dependencies of target tactile_msgs__rosidl_typesupport_fastrtps_cpp[0m
[ 31%] [32mBuilding CXX object CMakeFiles/tactile_msgs__rosidl_typesupport_introspection_cpp.dir/rosidl_typesupport_introspection_cpp/tactile_msgs/msg/tactile_signal__type_support.cpp.o[0m
[ 34%] [32mBuilding CXX object CMakeFiles/tactile_msgs__rosidl_typesupport_fastrtps_cpp.dir/rosidl_typesupport_fastrtps_cpp/tactile_msgs/msg/dds_fastrtps/tactile_signal__type_support.cpp.o[0m
[35m[1mScanning dependencies of target tactile_msgs__rosidl_typesupport_c[0m
[ 37%] [32mBuilding CXX object CMakeFiles/tactile_msgs__rosidl_typesupport_c.dir/rosidl_typesupport_c/tactile_msgs/msg/tactile_signal__type_support.cpp.o[0m
[35m[1mScanning dependencies of target tactile_msgs__rosidl_typesupport_introspection_c[0m
[ 40%] [32mBuilding C object CMakeFiles/tactile_msgs__rosidl_typesupport_introspection_c.dir/rosidl_typesupport_introspection_c/tactile_msgs/msg/tactile_signal__type_support.c.o[0m
[ 42%] [32m[1mLinking CXX shared library libtactile_msgs__rosidl_typesupport_c.so[0m
[ 45%] [32m[1mLinking C shared library libtactile_msgs__rosidl_typesupport_introspection_c.so[0m
[ 45%] Built target tactile_msgs__rosidl_typesupport_c
[ 45%] Built target tactile_msgs__rosidl_typesupport_introspection_c
[ 48%] [32m[1mLinking CXX shared library libtactile_msgs__rosidl_typesupport_cpp.so[0m
[ 51%] [32m[1mLinking CXX shared library libtactile_msgs__rosidl_typesupport_introspection_cpp.so[0m
[ 51%] Built target tactile_msgs__rosidl_typesupport_cpp
[ 51%] Built target tactile_msgs__rosidl_typesupport_introspection_cpp
[ 54%] [32m[1mLinking CXX shared library libtactile_msgs__rosidl_typesupport_fastrtps_cpp.so[0m
[ 54%] Built target tactile_msgs__rosidl_typesupport_fastrtps_cpp
[ 57%] [34m[1mGenerating C type support for eProsima Fast-RTPS[0m
[35m[1mScanning dependencies of target tactile_msgs__rosidl_typesupport_fastrtps_c[0m
[ 60%] [32mBuilding CXX object CMakeFiles/tactile_msgs__rosidl_typesupport_fastrtps_c.dir/rosidl_typesupport_fastrtps_c/tactile_msgs/msg/tactile_signal__type_support_c.cpp.o[0m
[ 62%] [32m[1mLinking CXX shared library libtactile_msgs__rosidl_typesupport_fastrtps_c.so[0m
[ 62%] Built target tactile_msgs__rosidl_typesupport_fastrtps_c
[35m[1mScanning dependencies of target tactile_msgs[0m
[ 62%] Built target tactile_msgs
[35m[1mScanning dependencies of target tactile_msgs_matlab[0m
[35m[1mScanning dependencies of target tactile_msgs__py[0m
[ 65%] [34m[1mGenerating Python code for ROS interfaces[0m
gmake[2]: *** No rule to make target '/usr/lib/x86_64-linux-gnu/libz.so', needed by 'libtactile_msgs_matlab.so'. Stop.
gmake[2]: *** Waiting for unfinished jobs....
[ 71%] [32mBuilding CXX object CMakeFiles/tactile_msgs_matlab.dir/src/tactile_msgs_TactileSignal_common.cpp.o[0m
[ 71%] [32mBuilding CXX object CMakeFiles/tactile_msgs_matlab.dir/src/tactile_msgs_msg_TactileSignal_publisher.cpp.o[0m
[ 74%] [32mBuilding CXX object CMakeFiles/tactile_msgs_matlab.dir/src/tactile_msgs_msg_TactileSignal_subscriber.cpp.o[0m
[ 74%] Built target tactile_msgs__py
[35m[1mScanning dependencies of target tactile_msgs__python[0m
[ 77%] [32mBuilding C object CMakeFiles/tactile_msgs__python.dir/rosidl_generator_py/tactile_msgs/msg/_tactile_signal_s.c.o[0m
/var/home/alex/devel/finger_perception/matlab_msg_gen/glnxa64/build/tactile_msgs/rosidl_generator_py/tactile_msgs/msg/_tactile_signal_s.c:11:10: fatal error: numpy/ndarrayobject.h: No such file or directory
#include "numpy/ndarrayobject.h"
^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
gmake[2]: *** [CMakeFiles/tactile_msgs__python.dir/build.make:82: CMakeFiles/tactile_msgs__python.dir/rosidl_generator_py/tactile_msgs/msg/_tactile_signal_s.c.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:547: CMakeFiles/tactile_msgs__python.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs....
gmake[1]: *** [CMakeFiles/Makefile2:142: CMakeFiles/tactile_msgs_matlab.dir/all] Error 2
gmake: *** [Makefile:160: all] Error 2
Alexander Wang
Alexander Wang on 31 Jul 2020
Hi Cam, thanks for your efforts.
I have moved to Ubuntu 20 now. But the last problem of numpy header persists. Is there any way to manually specify the include directories?

Sign in to comment.

More Answers (0)

Products


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!