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

119 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

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
  12 Comments
Andrei Alexeev
Andrei Alexeev on 10 Aug 2021
Hello together,
for last few days I also had problems to generate the custom messages.
Finally I came across the right solution and would like to briefly show what steps are needed to install it correctly.
To build the custom messages you need CMake, Python 3.7 and the ROS Toolbox.
For CMake:
2. download version 3.20.5 as *.sh
mkdir ~/cmake-install
mv cmake-<version>.sh ~/cmake-install/
% move to ~/cmake-install/ and execute installer
./cmake-<version>.sh
% Finally add these lines to ~/.bashrc
export PATH=$HOME/cmake-install/bin:$PATH
export CMAKE_PREFIX_PATH=$HOME/cmake-install:$CMAKE_PREFIX_PATH
For Python:
For this I installed version 3.7+.
% install dependencies
sudo apt update
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
cd /tmp
% download python 3.7+
wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tar.xz
tar -xf Python-3.7.2.tar.xz
cd Python-3.7.2
% prepare for compiling. --enable-shared is important when linking
% libpython
./configure --enable-shared
make
sudo make altinstall
When building custom messages colcon will need numpy-headers.
Attention: It does not have to be the 3.7.2 installation where you install numpy. Colcon does not care about the virtual environment which ros2 creates.
% install numpy
python3 -m pip install numpy
---
Now run Matlab and hit pyenv. If Version 3.7.2 does not appear, hit:
pyenv('Version', "</path/to/python3.7>")
Check also if CMake has been installed correctly. Hit
% No errors should appear
!cmake --version
From here everything should work fine. Select your path to your messages und run the build.

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!