CyberSource / cybersource-rest-samples-python

Sample code to demonstrate using the CyberSource REST APIs with the Python client library.
MIT License
27 stars 30 forks source link

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

Open agawronski opened 4 years ago

agawronski commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

Thanks @agawronski

brianmc commented 4 years ago

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

raieru commented 4 years ago

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