Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running samples: ModuleNotFoundError: No module named 'Crypto' #42

Open
agawronski opened this issue Jun 18, 2020 · 4 comments
Open

Running samples: ModuleNotFoundError: No module named 'Crypto' #42

agawronski opened this issue Jun 18, 2020 · 4 comments

Comments

@agawronski
Copy link

agawronski commented Jun 18, 2020

Hi trying to follow the basic instructions to test the sample code.

From: https://github.com/CyberSource/cybersource-rest-samples-python

trying to run: Running the Samples From the Command Line

git clone https://github.com/CyberSource/cybersource-rest-samples-python.git

pip3 install cybersource-rest-client-python

# Install the Sample Codes (required for running Authentication samples only)
cd cybersource-rest-samples-python
pip3 install -e .


python3 samples/RiskManagement/DecisionManager/mark-as-suspect.py

Traceback (most recent call last):
  File "samples/RiskManagement/DecisionManager/mark-as-suspect.py", line 1, in <module>
    from CyberSource import *
  File "C:\Users\agawronski\AppData\Local\Programs\Python\Python37\lib\site-packages\CyberSource\__init__.py", line 686, in <module>
    from .utilities.flex.token_verification import TokenVerification
  File "C:\Users\agawronski\AppData\Local\Programs\Python\Python37\lib\site-packages\CyberSource\utilities\__init__.py", line 4, in <module>
    from .flex.token_verification import TokenVerification
  File "C:\Users\agawronski\AppData\Local\Programs\Python\Python37\lib\site-packages\CyberSource\utilities\flex\__init__.py", line 4, in <module>
    from .token_verification import TokenVerification
  File "C:\Users\agawronski\AppData\Local\Programs\Python\Python37\lib\site-packages\CyberSource\utilities\flex\token_verification.py", line 1, in <module>
    from . import rsa_verify
  File "C:\Users\agawronski\AppData\Local\Programs\Python\Python37\lib\site-packages\CyberSource\utilities\flex\rsa_verify.py", line 1, in <module>
    from Crypto.PublicKey import RSA
ModuleNotFoundError: No module named 'Crypto'

All of the commands prior to running mark-as-suspect.py were successful.

@agawronski
Copy link
Author

The fix was to rename "crypto" -> "Crypto" in Python37/Lib/site-packages/.
Then inside of Python37/Lib/site-packages/Crypto/ to rename these directories with the proper case:
Crypto.Signature
Crypto.Math
Random
Crypto.Util
Crypto.PublicKey

I'm not sure why Crypto installs improperly, with all lowercase, but I found many cases of this occuring for other users on Windows online.

@brianmc
Copy link
Contributor

brianmc commented Jun 18, 2020

Thanks @agawronski

@brianmc
Copy link
Contributor

brianmc commented Jun 19, 2020

I just faced same issue so I'm going to reopen this just to see if there is a better solve than having modify another package

@brianmc brianmc reopened this Jun 19, 2020
@raieru
Copy link

raieru commented Oct 8, 2020

I face same issue and solve modifying the name. crypto -> Crypto

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants