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.

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

website for v0.2.0:

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

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

Download: see

How to install clamd:

  • For Windows: you need an unofficial version from or ( does not provide clamd anymore, and neither does ClamWin)

    o Before running clamd, edit clamd.conf and make sure it is configured

    to use a TCP port instead of a Unix socket: LocalSocket should be disabled, TCPSocket and TCPAddr should be enabled.

  • For MacOSX: you may install ClamXav, and then run clamd from /usr/local/clamXav/sbin.

  • For other operating systems such as Linux and *BSD:

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 >>> cd = pyclamd.ClamdUnixSocket() >>> try: ... ... except pyclamd.ConnectionError: ... cd = pyclamd.ClamdNetworkSocket() ... ... True >>> cd.version().split()[0] 'ClamAV' >>> cd.reload() 'RELOADING' >>> cd.stats().split()[0] 'POOLS:' >>> open('/tmp/EICAR','w').write(cd.EICAR()) >>> open('/tmp/NO_EICAR','w').write('no virus in this file') >>> cd.scan_file('/tmp/EICAR') {'/tmp/EICAR': ('FOUND', 'Eicar-Test-Signature')} >>> cd.scan_file('/tmp/NO_EICAR') is None True >>> cd.scan_stream(cd.EICAR()) {'stream': ('FOUND', 'Eicar-Test-Signature')} >>>