robotpy/examples

[BUG]: ModuleNotFoundError: No module named 'commands2'

KenwoodFox opened this issue · 3 comments

Problem description

When attempting to run any of the commands v2 examples, i get the following error:

python robot.py sim
Traceback (most recent call last):
  File "/home/joe/git/pre2022season/rio2/robot.py", line 5, in <module>
    import commands2
ModuleNotFoundError: No module named 'commands2'

I imagine that im just missing a module, but i looked through the docs and did not find anything. Perhaps its something like robotpy[commands2]?

Operating System

Windows, Linux

Installed Python Packages

action-tutorials-py==0.14.3
ament-clang-format==0.10.6
ament-clang-tidy==0.10.6
ament-cmake-google-benchmark==1.1.4
ament-cmake-test==1.1.4
ament-copyright==0.10.6
ament-cppcheck==0.10.6
ament-cpplint==0.10.6
ament-flake8==0.10.6
ament-index-python==1.2.0
ament-lint==0.10.6
ament-lint-cmake==0.10.6
ament-mypy==0.10.6
ament-package==0.12.0
ament-pclint==0.10.6
ament-pep257==0.10.6
ament-pycodestyle==0.10.6
ament-pyflakes==0.10.6
ament-uncrustify==0.10.6
ament-xmllint==0.10.6
catkin-pkg==0.4.24
demo-nodes-py==0.14.3
docutils==0.18.1
domain-coordinator==0.9.2
examples-rclpy-executors==0.11.2
examples-rclpy-guard-conditions==0.11.2
examples-rclpy-minimal-action-client==0.11.2
examples-rclpy-minimal-action-server==0.11.2
examples-rclpy-minimal-client==0.11.2
examples-rclpy-minimal-publisher==0.11.2
examples-rclpy-minimal-service==0.11.2
examples-rclpy-minimal-subscriber==0.11.2
examples-rclpy-pointcloud-publisher==0.11.2
examples-tf2-py==0.17.2
interactive-markers==2.2.0
launch==0.17.0
launch-ros==0.14.2
launch-testing==0.17.0
launch-testing-ros==0.14.2
launch-xml==0.17.0
launch-yaml==0.17.0
osrf-pycommon==0.2.1
pynetworktables==2021.0.0
pyntcore==2022.2.1.1
pyparsing==3.0.7
python-dateutil==2.8.2
python-qt-binding==1.0.7
qt-dotgraph==2.0.1
qt-gui==2.0.1
qt-gui-cpp==2.0.1
qt-gui-py-common==2.0.1
quality-of-service-demo-py==0.14.3
rclpy==1.9.0
rcutils==4.0.2
resource-retriever==2.5.0
robotpy-hal==2022.2.1.1
robotpy-wpimath==2022.2.1.4
robotpy-wpiutil==2022.2.1.1
ros2action==0.13.1
ros2bag==0.9.0
ros2cli==0.13.1
ros2component==0.13.1
ros2doctor==0.13.1
ros2interface==0.13.1
ros2launch==0.14.2
ros2lifecycle==0.13.1
ros2multicast==0.13.1
ros2node==0.13.1
ros2param==0.13.1
ros2pkg==0.13.1
ros2run==0.13.1
ros2service==0.13.1
ros2test==0.3.0
ros2topic==0.13.1
ros2trace==2.3.0
rosbag2-py==0.9.0
rosidl-adapter==2.2.1
rosidl-cli==2.2.1
rosidl-cmake==2.2.1
rosidl-generator-c==2.2.1
rosidl-generator-cpp==2.2.1
rosidl-generator-dds-idl==0.8.0
rosidl-generator-py==0.11.0
rosidl-parser==2.2.1
rosidl-runtime-py==0.9.1
rosidl-typesupport-c==1.2.1
rosidl-typesupport-cpp==1.2.1
rosidl-typesupport-fastrtps-c==1.2.1
rosidl-typesupport-fastrtps-cpp==1.2.1
rosidl-typesupport-introspection-c==2.2.1
rosidl-typesupport-introspection-cpp==2.2.1
rpyutils==0.2.0
rqt==1.1.1
rqt-action==2.0.0
rqt-bag==1.1.1
rqt-bag-plugins==1.1.1
rqt-console==2.0.1
rqt-graph==1.2.0
rqt-gui==1.1.1
rqt-gui-py==1.1.1
rqt-msg==1.0.4
rqt-plot==1.0.10
rqt-publisher==1.1.3
rqt-py-common==1.1.1
rqt-py-console==1.0.1
rqt-reconfigure==1.0.8
rqt-service-caller==1.0.4
rqt-shell==1.0.1
rqt-srv==1.0.2
rqt-top==1.0.1
rqt-topic==1.2.1
sensor-msgs-py==2.2.3
six==1.16.0
sros2==0.10.2
test-launch-ros==0.14.2
tf2-kdl==0.17.2
tf2-py==0.17.2
tf2-ros-py==0.17.2
tf2-tools==0.17.2
topic-monitor==0.14.3
tracetools-launch==2.3.0
tracetools-read==2.3.0
tracetools-trace==2.3.0
wpilib==2022.2.1.5


### Reproducible example code

```text
❯ cat script.py
#!/usr/bin/env python3

import commands2
❯ python script.py
Traceback (most recent call last):
  File "/home/joe/git/pre2022season/rio2/script.py", line 3, in <module>
    import commands2
ModuleNotFoundError: No module named 'commands2'

The solution was to add commands2 to the extras in your requirements or pipenv.

[packages]
robotpy = {extras = ["commands2"], version = "*"}

I don't know anything about pipenv (I use virtualenvwrapper), but if you think it's something that others might benefit from you could write a small set of instructions on how to properly set it up for our documentation?

https://robotpy.readthedocs.io/en/stable/install/computer.html#install-computer might make sense. Or a separate page there.

I think pipenv install "robotpy[commands2] would do the right thing.