FortiSOAR Knowledge Base
FortiSOAR: Security Orchestration and Response software provides innovative case management, automation, and orchestration. It pulls together all of an organization's tools, helps unify operations, and reduce alert fatigue, context switching, and the mean time to respond to incidents.
Article Id 314752


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


2024-05-13 11_40_59-CodeSNippet _ 01 - Drafts _ Collections _ Playbooks and 3 more pages - Work - Mi.png


2024-05-13 11_42_32-.png




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:,
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.


2024-05-13 11_53_35-Code Snippet Module Installation Demo _ 01 - Drafts _ Collections _ Playbooks an.png