Robotics StackExchange | Archived questions

No module named 'Cryptodomex' error when running rosmsg show

My system is ROS melodic / Ubuntu 18.04.

I tried to do rosmsg show [msg], but it returns this error:

dlee640@dlee640-ThinkPad-T580:~$ rosmsg show nav_msgs/Odometry 
Traceback (most recent call last):
  File "/opt/ros/melodic/bin/rosmsg", line 35, in <module>
    rosmsg.rosmsgmain()
  File "/opt/ros/melodic/lib/python2.7/dist-packages/rosmsg/__init__.py", line 754, in rosmsgmain
    sys.exit(rosmsg_cmd_show(ext, full, command))
  File "/opt/ros/melodic/lib/python2.7/dist-packages/rosmsg/__init__.py", line 582, in rosmsg_cmd_show
    import rosbag
  File "/opt/ros/melodic/lib/python2.7/dist-packages/rosbag/__init__.py", line 33, in <module>
    from .bag import Bag, Compression, ROSBagException, ROSBagFormatException, ROSBagUnindexedException
  File "/opt/ros/melodic/lib/python2.7/dist-packages/rosbag/bag.py", line 53, in <module>
from Cryptodome.Cipher import AES
ModuleNotFoundError: No module named 'Cryptodome'

I have searched this issue and the recommended solution was to

pip install pycryptodomex

which returns

Requirement already satisfied: pycryptodomex in ./.pyenv/versions/3.8.6/lib/python3.8/site-packages (3.9.7)

Other than above, I have also tried

pip3 install pycryptodomex
pip3 install pycrypto
pip3 install Cryptodome

None of these seem to work. All the installation goes successful, but I think the problem is related to ROS not being able to locate the pycryptodomex property due to python version. I have tried normal pip instead of pip3 as well, so that is not the solution I am looking for.

Can someone guide me where to look for to address this issue?

Thank you.

Asked by buzzport93 on 2021-01-31 03:00:02 UTC

Comments

Answers

I was able to solve this issue by replacing the first line in the file at "/opt/ros/melodic/bin/rosmsg" Previous: #!/usr/bin/python After: #!/usr/bin/python2.7

Asked by buzzport93 on 2021-01-31 13:45:41 UTC

Comments

Beside my post https://answers.ros.org/question/370678/no-module-named-cryptodomex-error-when-running-rosmsg-show/?answer=370930#post-id-370930 is likely more proper fix, using pip is ok but in general not recommended esp. if you're making software that's meant to be maintained longer term. FYI there's lengthy discussion https://discourse.ros.org/t/should-we-warn-new-users-about-difficulties-with-python-3-and-alternative-python-interpreters/3874

Asked by 130s on 2021-02-03 06:54:18 UTC

Indeed in bag.py Cryptodome is referenced (permalink to the latest melodic-devel at the time):

from Cryptodome.Cipher import AES

Unfamilliar with this package, I'm curious where the dependency on this pkg is defined.

Barebone Ubuntu distro, or default python? Looks like no.

$ docker run -it ubuntu:bionic bash
# apt update && apt install python
# python -c "import Cryptodome"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named Cryptodome

Somewhere in base ROS? Looks like it.

$ docker run -it ros:melodic-ros-base bash
root@ccde9d6e77bd:/# python -c "import Cryptodome"
root@ccde9d6e77bd:/# 
# apt-cache policy python-pycryptodome
python-pycryptodome:
  Installed: 3.4.7-1ubuntu1
  Candidate: 3.4.7-1ubuntu1
  Version table:
 *** 3.4.7-1ubuntu1 100
        100 /var/lib/dpkg/status

Indeed rosbag package itself defines it.

So, if you followed any standard way to (build/)install rosbag (and others), the missing package should have been beautifully installed automatically (by rosdep install that references to package.xml of each package and installs missing packages). I can only recommend that you review your installation steps. But, b/c there are other people who are stuck with the same error msg e.g. #q331160, I'd say there may be a corner case that the installtion steps haven't captured yet (In that case we should fix. Please consider updating your description, or open a ticket. For a starter I'd say ros_comm is ok).

Asked by 130s on 2021-02-03 06:49:22 UTC

Comments