Python Script failing on Crypto.Cipher

Hi, we’re starting to implement running Python scripts in process steps. We’re trying to run the following simple python script on a deployment target…

import os
print("PATH: {0}".format(os.environ['PATH']))

We are getting the following error from the console.

Variable run condition was evaluated as true, so “Run Python” will be run.
March 24th 2022 08:19:42Info
Requirement already satisfied: pycryptodome in c:\users\myUserName\appdata\roaming\python\python37\site-packages (3.14.1)
March 24th 2022 08:19:42Error
Traceback (most recent call last):
March 24th 2022 08:19:42Error
File “D:\Octopus\Tentacle-DMZ\Work\20220324151936-26118-4\Bootstrap.067-4782-8e43-3d794ea5a441.Script.py”, line 2, in
March 24th 2022 08:19:42Error
configuration = run_path(“D:\Octopus\Tentacle-DMZ\Work\20220324151936-26118-4\Configure.2ab-4590-a4b4-2a33bf32ea7b.py”)
March 24th 2022 08:19:42Error
File “C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\runpy.py”, line 263, in run_path
March 24th 2022 08:19:42Error
pkg_name=pkg_name, script_name=fname)
March 24th 2022 08:19:42Error
File “C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\runpy.py”, line 96, in _run_module_code
March 24th 2022 08:19:42Error
mod_name, mod_spec, pkg_name, script_name)
March 24th 2022 08:19:42Error
File “C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\runpy.py”, line 85, in run_code
March 24th 2022 08:19:42Error
exec(code, run_globals)
March 24th 2022 08:19:42Error
File “D:\Octopus\Tentacle-DMZ\Work\20220324151936-26118-4\Configure.2ab-4590-a4b4-2a33bf32ea7b.py”, line 5, in
March 24th 2022 08:19:42Error
from Crypto.Cipher import AES
March 24th 2022 08:19:42Error
File "C:\Users\myUserName\AppData\Roaming\Python\Python37\site-packages\Crypto\Cipher_init
.py", line 27, in
March 24th 2022 08:19:42Error
from Crypto.Cipher._mode_ecb import _create_ecb_cipher
March 24th 2022 08:19:42Error
File “C:\Users\myUserName\AppData\Roaming\Python\Python37\site-packages\Crypto\Cipher_mode_ecb.py”, line 47, in
March 24th 2022 08:19:42Error
“”"
March 24th 2022 08:19:42Error
File “C:\Users\myUserName\AppData\Roaming\Python\Python37\site-packages\Crypto\Util_raw_api.py”, line 309, in load_pycryptodome_raw_lib
March 24th 2022 08:19:42Error
raise OSError(“Cannot load native module ‘%s’: %s” % (name, ", ".join(attempts)))
March 24th 2022 08:19:42Error
OSError: Cannot load native module ‘Crypto.Cipher._raw_ecb’: Not found ‘_raw_ecb.cp37-win_amd64.pyd’, Cannot load ‘_raw_ecb.pyd’: cannot load library ‘C:\Users\myUserName\AppData\Roaming\Python\Python37\site-packages\Crypto\Util…\Cipher_raw_ecb.pyd’: error 0xc1
March 24th 2022 08:19:42Fatal
The remote script failed with exit code 1
March 24th 2022 08:19:42Fatal
The action Run Python on MaPIT AGS Stage failed

Any ideas?

Thanks,
Robert

Hi @rblischke,

Thanks for getting in touch!
Sorry to hear that you’re experiencing issues.

I’ve taken a look at the stack trace and it seems like one of the dependencies required for our Configure.py script is missing, specifically from the command “from Crypto.Cipher import AES”.

It may be worth making sure that all the correct requirements in the python script I’ve linked above are included on your target machine.
Specifically for the error you’ve experienced, it may be worth performing a clear-out of any old modules that may be causing some inconsistencies.

On the target machine, can you run these with your version of pip (pip or pip3):

pip uninstall crypto
pip uninstall pycrypto
pip uninstall pycryptodome
pip install pycryptodome

This will ensure the correct module is used when that script is called.
It’s also worth making sure that you’re using a Python version of at least 3.4+ in order to work correctly with Octopus.

I hope this helps! Please let me know if you have any questions or concerns and any progress you make.

Kind Regards,
Adam

Hi @adam.hollow ,

Thanks for the prompt advice.

So, before your response, I tried to install “pycrypto”, because of the issue of not finding some of the libraries. “Pycrypto” didn’t fully install because I was missing some C++ libraries.

I then ran the pip commands you suggested…

That seemed to fix the issue.

I am able to run the python script on that machine.

Thanks again for your help,
Robert

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.