ROS2 Foxy on Windows 10 - command line tools not working
Hello,
I have installed ROS2 Foxy on Windows 10 using the directions located here: https://ms-iot.github.io/ROSOnWindows...
The installation seemed to work OK but I am having errors when I run some of the command line tools. Currently, I am trying to learn by watching YouTube videos (which are geared towards ROS2 on Linux) and apply the content to Windows. I can run the example talker/listener without error and even run my own simple Python nodes.
But using commands like "ros2 node list" or "ros2 topic list" do not work. Here is an example:
C:\Windows\System32>ros2 topic list
Failed to load entry point 'list': [WinError 193] %1 is not a valid Win32 application
Traceback (most recent call last):
File "c:\opt\ros\foxy\x64\Scripts\ros2-script.py", line 33, in <module>
sys.exit(load_entry_point('ros2cli==0.9.10', 'console_scripts', 'ros2')())
File "c:\opt\ros\foxy\x64\lib\site-packages\ros2cli\cli.py", line 39, in main
add_subparsers_on_demand(
File "c:\opt\ros\foxy\x64\lib\site-packages\ros2cli\command\__init__.py", line 250, in add_subparsers_on_demand
extension.add_arguments(
File "c:\opt\ros\foxy\x64\lib\site-packages\ros2topic\command\topic.py", line 29, in add_arguments
add_subparsers_on_demand(
File "c:\opt\ros\foxy\x64\lib\site-packages\ros2cli\command\__init__.py", line 237, in add_subparsers_on_demand
extension = command_extensions[name]
KeyError: 'list'
when I run "ros2 doctor --report" I get the following error message
C:\Windows\System32>ros2 doctor --report
Traceback (most recent call last):
File "c:\opt\ros\foxy\x64\Scripts\ros2-script.py", line 33, in <module>
sys.exit(load_entry_point('ros2cli==0.9.10', 'console_scripts', 'ros2')())
File "c:\opt\ros\foxy\x64\lib\site-packages\ros2cli\cli.py", line 67, in main
rc = extension.main(parser=parser, args=args)
File "c:\opt\ros\foxy\x64\lib\site-packages\ros2doctor\command\doctor.py", line 51, in main
all_reports = generate_reports()
File "c:\opt\ros\foxy\x64\lib\site-packages\ros2doctor\api\__init__.py", line 121, in generate_reports
report_class = report_entry_pt.load()
File "c:\opt\ros\foxy\x64\lib\site-packages\pkg_resources\__init__.py", line 2447, in load
return self.resolve()
File "c:\opt\ros\foxy\x64\lib\site-packages\pkg_resources\__init__.py", line 2453, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "c:\opt\ros\foxy\x64\lib\site-packages\ros2doctor\api\topic.py", line 17, in <module>
from ros2cli.node.direct import DirectNode
File "c:\opt\ros\foxy\x64\lib\site-packages\ros2cli\node\direct.py", line 18, in <module>
import rclpy.action
File "c:\opt\ros\foxy\x64\lib\site-packages\rclpy\action\__init__.py", line 15, in <module>
from .client import ActionClient # noqa: F401
File "c:\opt\ros\foxy\x64\lib\site-packages\rclpy\action\client.py", line 32, in <module>
from unique_identifier_msgs.msg import UUID
File "c:\opt\ros\foxy\x64\lib\site-packages\unique_identifier_msgs\msg\__init__.py", line 1, in <module>
from unique_identifier_msgs.msg._uuid import UUID # noqa: F401
File "c:\opt\ros\foxy\x64\lib\site-packages\unique_identifier_msgs\msg\_uuid.py", line 9, in <module>
import numpy # noqa: E402, I100
File "C:\Users\henry\AppData\Roaming\Python\Python38\site-packages\numpy\__init__ ...
quick comment: this could be due to mismatching Python versions. Python-on-Windows (and Windows in general) is picky about this. See ros2/ros2#525 for a similar report.
Make sure you have no alternative Python interpreters 'activated' or taking the default spot in the search order. The second backtrace shows paths in
C:\Users\henry\AppData\Roaming\Python\Python38
which seems to suggest something is installed there which interferes.Thank you! I was worried about this... Python was already installed on this machine and I use it all the time. It seems that ROS2 is sometimes picking up things from the "other" python.
I tried to follow the directions in the post you recommended: in C:\opt\ros\foxy\x64\Scripts\ros2-script.py the first line was changed from
to
but that had even worse results and running ros2 from the prompt resulted in "failed to create process."
Is there a procedure for having a non-ROS2 Python installation exist? Do you think I would be better off starting a new question with the assumption that this is the cause of the problem?
Thanks again for your help.
Unfortunately, I've got no helpful advice I believe. I've never really used ROS 2 on Windows -- at least not for any real work.
I do know -- from reading interactions between others who do use ROS 2 on Windows -- that you can't really change the version of Python used with your ROS 2 installation, as ROS 2 uses quite a few native extensions (ie: C/C++ compiled into
.dll
s) which get loaded by Python at runtime. The version of Python loading the extensions and the one used to build them must match.That could be the cause of what you're seeing.
Thank you for your help - it highlighted the problem with the Python versions.
I'm not sure how to solve it in a nice way. I can't just remove all other development tools from this computer - I will try creating a new user and just install ROS2 on that user account. Maybe that will keep it separate. Using ROS2 on Windows is extremely frustrating.
You could perhaps comment on the issue I linked.
Or post a new question, with just the Python versioning problem as the subject.
Or ask Microsoft. Depending on whether you're using the "ROS 2 Windows binary archive" or the Microsoft supported install of course.
Even though I don't have a lot of experience with it, what bit me the most was just the difference between Windows and Linux development practices -- including environment setup.
wouldn't careful attention to how
PATH
s are configured be a possible way to manage this?That'd be almost like working with
venvs
.Only if you're working with ROS would you need the
python.exe
inc:\opt\ros\foxy\x64
on the%PATH%
.Similar to how
vcvarsall.bat
manages paths for the ...(more)