AnsweredAssumed Answered

Error Pasting to Clipboard with Python in ArcMap 10.6

Question asked by P_Jutson on Feb 23, 2018
Latest reply on Feb 26, 2018 by P_Jutson

Error Pasting to Clipboard with Python in ArcMap 10.6


I have been testing an existing Python Add-In written for ArcMap 10.2 that throws an error in ArcMap 10.6. The error was 'module' object has no attribute 'argv'.  After checking the web it looked like code I used to past to the clipboard with Tkinker was the problem. To test I copied the following code from the Add-In and pasted into the Python Window and an error was generated on usage.


>>> import Tkinter

>>> def toClipboard(txt):

...     clip = Tkinter.Tk()

...     clip.withdraw()

...     clip.clipboard_clear()

...     clip.clipboard_append(txt)

...     clip.destroy()


>>> toClipboard("Hello")

Runtime error

Traceback (most recent call last):

  File "<string>", line 1, in <module>

  File "<string>", line 2, in toClipboard

  File "C:\Python27\ArcGIS10.6\Lib\lib-tk\", line 1814, in __init__

    baseName = os.path.basename(sys.argv[0])

AttributeError: 'module' object has no attribute 'argv'



In ArcMap 10.2 this code runs without a problem. The wisdom of the web suggests that a similar problem happened in ArcMap 10.1 and could be to do with the way sys has been altered for ArcGIS.


Have I found a bug?