pyClamd - use ClamAV antivirus from Python

pyClamd is a portable Python module to use the ClamAV antivirus engine on Windows, Linux, MacOSX and other platforms. It requires a running instance of the clamd daemon. pyClamd is more portable than pyClamAV because it does not need to be compiled, so it works on Windows.

This is a slightly improved version of pyClamd v0.1.1 originally created by Alexandre Norman and published on his website:

Improvements from version 0.1.1 to 0.2.0:

  • added option to set a timeout on scans
  • fixed warning due to string exceptions with Python 2.5


pyClamd is released as open-source software under the GPLv2 license.


Click on the link below to download the zip file.

How to install clamd:


How to run clamd as a service on Windows:
See or

There used to be instructions on to use either runclamd or the NJH Power Tools, but the website is not available anymore.

How to use pyClamd:

See source code or Alexandre Norman's website:

Here is an example on Unix:

$ python
>>> import pyclamd
>>> pyclamd.init_unix_socket('/tmp/clamd.socket')
>>> pyclamd.version()
'ClamAV 0.95.3/10512/Thu Mar  4 14:17:23 2010'
>>> pyclamd.scan_stream(pyclamd.EICAR)
{'stream': 'Eicar-Test-Signature FOUND'}
>>> pyclamd.scan_stream('a clean string')
>>> pyclamd.scan_file('/tmp/clean.txt')
>>> f=open('/tmp/eicar.bin','wb')
>>> f.write(pyclamd.EICAR)
>>> f.close()
>>> pyclamd.scan_file('/tmp/eicar.bin')
{'/tmp/eicar.bin': 'Eicar-Test-Signature'}
>>> import os
>>> os.remove('/tmp/eicar.bin')



pyclamd-0.2.0.zip11.44 KB