This article describes the solution for the 'ModuleNotFoundError' error on the CodeSnippet Connector. Assuming the xlsxwriter module is required on the codesnippet connector to create certain functions, it is common to encounter this 'ModuleNotFoundError' only when the required module isn't installed on the system.
Invalid code snippet: line 1, in <module>\nModuleNotFoundError: No module named 'xlsxwriter'\n Connector :: code-snippetV2.1.1
FortiSOAR v7.x.
Step 1: Install the required module with the following command using pip install <modulename>.
sudo -u fsr-integrations /opt/cyops-integrations/.env/bin/pip install XlsxWrite
Looking in indexes: https://pypi.org/simple, https://repo.fortisoar.fortinet.com/prod/connectors/deps/simple/
Collecting XlsxWriter
Using cached XlsxWriter-3.2.0-py3-none-any.whl (159 kB)
Installing collected packages: XlsxWriter
Successfully installed XlsxWriter-3.2.0
Step 2: Check whether the installed module is listed on the global pip.
sudo -u fsr-integrations /opt/cyops-integrations/.env/bin/pip list | grep -i xlsxWrite
XlsxWriter 3.2.0
Step 3: Remove the __pycache__ and restart the uWSGI services.
sudo rm -rf /opt/cyops/configs/integrations/packages/lib/python3.9/site-packages/__pycache__/
sudo rm -rf /opt/cyops-integrations/.env/lib/python3.9/site-packages/__pycache__/
sudo systemctl restart uwsgi
Now, rerun the playbook and check again.
The Fortinet Security Fabric brings together the concepts of convergence and consolidation to provide comprehensive cybersecurity protection for all users, devices, and applications and across all network edges.
Copyright 2024 Fortinet, Inc. All Rights Reserved.