Ask Your Question
1

ImportError: No module named Crypto

asked 2019-08-20 10:12:02 -0500

iggy12345 gravatar image

updated 2019-08-20 10:19:52 -0500

gvdhoorn gravatar image

I'm having my coworker follow the directions on this page to install rosbag
http://wiki.ros.org/Installation/Windows
so that he can reindex corrupted .bag files in the future, we've followed the directions to a 'T' but are still receiving this import error:

Traceback (most recent call last):
  File "C:\opt\ros\melodic\x64\bin\rosbag", line 34, in <module>
    import rosbag
  File "C:\opt\ros\melodic\x64\lib\site-packages\rosbag\__init__.py", line 33, in <module>
    from .bag import Bag, Compression, ROSBagException, ROSBagFormatException, ROSBagUnindexedException
  File "C:\opt\ros\melodic\x64\lib\site-packages\rosbag\bag.py", line 53, in <module>
    from Crypto import Random
ImportError: No module named Crypto

we tried installing Crypto and pycrypto manually, which all come back as successfull, but the error persists

Specs:
Windows 10
64-Bit
Visual Studio 2019 Community Edition
2019 Build Tools, and the Microsoft C++ Compiler for Python 2.7
edit retag flag offensive close merge delete

Comments

Hello,

What was the solution to that problem?

Thanks in advance

LeRos gravatar image LeRos  ( 2020-05-14 11:40:29 -0500 )edit

I have a feeling this might not be a Windows specific issue. #q370678 shows the same error on Ubuntu.

130s gravatar image 130s  ( 2021-02-03 05:34:10 -0500 )edit

4 Answers

Sort by ยป oldest newest most voted
2

answered 2019-08-26 12:18:02 -0500

Yoshi_E gravatar image

updated 2019-08-26 16:23:49 -0500

Just ran into it while creating a new python environment. Solved it with: pip install pycryptodome

edit flag offensive delete link more

Comments

I passed that stage installing pycryptodomex but now I'm at ModuleNotFoundError: No module named 'gnupg'

Avio gravatar image Avio  ( 2020-07-16 08:57:16 -0500 )edit

How did you solve the problem? Thanks.

lyh458 gravatar image lyh458  ( 2020-09-23 07:21:00 -0500 )edit

I eventually gave up. I don't remember the problem exactly, IIRC I was trying to read the messages from the rosbag directly without doing rosbag play. In any case, my problem was elsewhere, I was losing packets because the pipeline in the rest of my code was too slow, so I solved it by optimizing the rest of the code.

Avio gravatar image Avio  ( 2020-09-23 07:45:19 -0500 )edit

I solved the problem by ran conda install -c conda-forge python-gnupg just now. Using ros and anaconda simultaneously maybe the cause of my problem. Thanks anyway.

lyh458 gravatar image lyh458  ( 2020-09-23 08:15:06 -0500 )edit

I checked out my git log, I gave up upon reaching the import roslz4 necessary to replay my bags. I didn't find the way to import it because it was Python 2.7 only and I was using Python 3.6. So unrelated to gnupg at the end of the day.

Avio gravatar image Avio  ( 2020-09-23 08:33:00 -0500 )edit

Beside my post https://answers.ros.org/question/3311... is likely more proper fix, using pipis _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...

130s gravatar image 130s  ( 2021-02-03 06:00:03 -0500 )edit
1

answered 2019-08-21 16:47:17 -0500

OoeyGUI gravatar image

Thank you for the report. This is the first I've seen of this, so I created a tracking bug in the ROS on Windows Github.

edit flag offensive delete link more
0

answered 2020-09-24 10:39:37 -0500

blubbi321 gravatar image

updated 2020-09-24 10:53:24 -0500

Arrived here searching for a solution to fixing ImportError: No module named Cryptodome.Cipher on Ubuntu 18.04 (one line above in the same source file that the OP is referred to in his stacktrace).

Solved by installing pip install pycryptodomex(suggested here https://github.com/IdentityPython/pys...)

edit flag offensive delete link more

Comments

Same as my comment on another answer, pip is not recommended esp. for longer term development.

130s gravatar image 130s  ( 2021-02-03 05:59:45 -0500 )edit
0

answered 2021-02-03 05:58:44 -0500

130s gravatar image

Same as the answer on another thread #q370678 (answer), a dependency on cryptodome is defined in the very rosbag package so it should be installed during (build/)installation of rosbag. I'd recommend you to review how you (build/)installed rosbag.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2019-08-20 10:12:02 -0500

Seen: 3,791 times

Last updated: Feb 03