• Home »
  • Errors »
  • Nmap 5.51: Zenmap: Error Saving Snapshot: Surface.write_to_png takes one argument which must be a filename (str)

Nmap 5.51: Zenmap: Error Saving Snapshot: Surface.write_to_png takes one argument which must be a filename (str)

I upgraded to Nmap 5.51 early this afternoon because a friend asked me to take a look at creating a topology image of a network scan of around 3,000 hosts. After upgrading I opened his scan in Zenmap and attempted to export the topology of the scan as a PNG but I received an error which I at first assumed was an issue on my computer or an issue with the fact that the export to PNG image was taking place on a 64-bit Windows 7 computer however both of those turned out to be incorrect. Below I describe the error in more detail as well as the current newest Nmap version that will allow PNG export, a workaround for the issue, and notes about the response from the Nmap development team that already pushed a fix to SVN only a couple hours after the issue was reported (+1 Nmap devs!).

Error Saving Snapshot Of Nmap Topology As PNG Via Zenmap:

Nmap Zenmap Surface.write_to_png Error

Error Exporting Topology PNG Text:

Error Saving Snapshot: Surface.write_to_png takes one argument which must be a filename (str), file object, or a file-like object which has a “write” method (like StringIO)

Error In zenmap.exe.log File Located In Nmap Root Folder On Windows 7:

C:Program Files (x86)Nmappy2exelibrary.zipzenmapGUIMainWindow.py:482: GtkWarning: Could not find the icon '"%1"'. The 'hicolor' theme
was not found either, perhaps you need to install it.
You can get a copy from:

http://icon-theme.freedesktop.org/releases

What I Attempted To Do To Resolve The Export To PNG Error:

The error was first noticed on a laptop running Windows 7 Ultimate 64-bit and I first wanted to rule out the 64-bit OS so I attempted to save a topology map on a Windows 7 Ultimate 32-bit machine but encountered the same results. Next I decided to roll back one version from Nmap 5.51 to Nmap 5.50 but also encountered the same results. I rolled back again to Nmap 5.36TEST4 which was the next latest Nmap version built as a win32 installer but also encountered the same results. I decided to try one more version which was Nmap 5.21 and with this version I was able to save a topology as a PNG image without issue. So one work around for now is to rollback to Nmap 5.21 if you have to save the topology image as a PNG though the recommended workaround is below.

Recommended Workaround For Exporting Topology Images Via Nmap Zenmap:

The recommended workaround would be to save the topology as a PDF first as shown in the below image.

Zenmap Save Topology As PDF

Next open the topology PDF in something like Adobe Photoshop and save it as either PNG or another preferred image type such as GIF or JPG. This way you don’t have to rollback Nmap to version 5.21 which was released in July of 2010.

Zenmap Export Topology As PNG Bug Reported To Nmap Devs:

After verifying the issue was not isolated to my computer or Windows 7 64-bit I sent an email to the Nmap devs and received a response quickly from David Fifield. He confirmed the issue existed in Windows and not in GNU/Linux and pointed out that the bug was really with pycairo. He submitted a workaround to Nmap SVN version r22250 which I should be in the next win32 installer released. Thanks David for the quick response and fix!


List Price: $49.95 USD
New From: $27.63 USD In Stock
Used from: $16.94 USD In Stock


List Price: $99.95 USD
New From: $108.65 USD In Stock
Used from: $40.20 USD In Stock

Share