<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using a text file to set label expression in ArcPy in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/using-a-text-file-to-set-label-expression-in-arcpy/m-p/503559#M39557</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I checked and it appears that only one version of Python is installed on the machine.&amp;nbsp; What's weird is that when I run the script from the add-in, I get the message "No module named arcpy".&amp;nbsp; However, when running it through the ArcMap console, I get the message "No module named numpy".&amp;nbsp; Would this mean that there is a numpy module that is missing?&amp;nbsp; Below is my code, I don't even see a reason why it would use numpy.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;import pythonaddins&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&lt;/P&gt;&lt;P&gt;lyr = pythonaddins.GetSelectedTOCLayerOrDataFrame()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if lyr.supports("LABELCLASSES"):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.showLabels = True&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.labelClasses[0].expression = "[FID]"&lt;/P&gt;&lt;P&gt;arcpy.RefreshActiveView()&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 05 Dec 2014 02:23:50 GMT</pubDate>
    <dc:creator>WesleyAskew</dc:creator>
    <dc:date>2014-12-05T02:23:50Z</dc:date>
    <item>
      <title>Using a text file to set label expression in ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/using-a-text-file-to-set-label-expression-in-arcpy/m-p/503552#M39550</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I am currently using the lyr.labelClasses[0].expression property to label features in ArcMap from a Python script.&amp;nbsp; I am wondering if it is possible to set this expression property from a string stored in a text document.&amp;nbsp; If so, what would be the best way of going about this?&amp;nbsp; Any help is greatly appreciated.&amp;nbsp; Thanks in advance.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Dec 2014 20:55:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-text-file-to-set-label-expression-in-arcpy/m-p/503552#M39550</guid>
      <dc:creator>WesleyAskew</dc:creator>
      <dc:date>2014-12-01T20:55:24Z</dc:date>
    </item>
    <item>
      <title>Re: Using a text file to set label expression in ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/using-a-text-file-to-set-label-expression-in-arcpy/m-p/503553#M39551</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;ConfigParser&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a simple usage:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Create the file label.ini with contents:&lt;/P&gt;&lt;P&gt;[label1]&lt;/P&gt;&lt;P&gt;name: Paul&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[label2]&lt;/P&gt;&lt;P&gt;color: Red&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you can use it like this:&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; import ConfigParser&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; config=ConfigParser.ConfigParser()&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; config.read("C:\\Users\\me\\Desktop\label.ini")&lt;/P&gt;&lt;P&gt;['C:\\Users\\me\\Desktop\\label.ini']&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; config.sections()&lt;/P&gt;&lt;P&gt;['label1', 'label2']&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; name = config.get("label1","name")&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; name&lt;/P&gt;&lt;P&gt;'Paul'&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; color=config.get("label2","color")&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt; color&lt;/P&gt;&lt;P&gt;'Red'&lt;/P&gt;&lt;P&gt;&amp;gt;&amp;gt;&amp;gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Dec 2014 21:07:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-text-file-to-set-label-expression-in-arcpy/m-p/503553#M39551</guid>
      <dc:creator>PaulCrickard1</dc:creator>
      <dc:date>2014-12-01T21:07:51Z</dc:date>
    </item>
    <item>
      <title>Re: Using a text file to set label expression in ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/using-a-text-file-to-set-label-expression-in-arcpy/m-p/503554#M39552</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your response.&amp;nbsp; Although this could potentially work, the issue is that I already have a .Net ArcObjects add-in which generates a fairly complex string based on numerous variables.&amp;nbsp; I need to use Python to drive the labeling and I want to pass this entire .Net generated string to the Python script.&amp;nbsp; Do you think that the method that you indicate will be suitable for this purpose?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Dec 2014 21:30:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-text-file-to-set-label-expression-in-arcpy/m-p/503554#M39552</guid>
      <dc:creator>WesleyAskew</dc:creator>
      <dc:date>2014-12-01T21:30:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using a text file to set label expression in ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/using-a-text-file-to-set-label-expression-in-arcpy/m-p/503555#M39553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Could work, but you have to write to text file first. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;maybe you could just call the python code from .NET and pass the string as a command line argument.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or use IronPython and combine .NET and Python in .NET or cimpile your .NET to DLL and call from python.&lt;/P&gt;&lt;P&gt;&lt;A href="http://ironpython.net/" title="http://ironpython.net/"&gt;IronPython.net /&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;A short post I did on it&lt;/P&gt;&lt;P&gt;&lt;A href="https://paulcrickard.wordpress.com/2013/05/16/python-in-c-using-ironpython/" title="https://paulcrickard.wordpress.com/2013/05/16/python-in-c-using-ironpython/"&gt;Python in C# Using IronPython | Architecture and Planning&lt;/A&gt; &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 01 Dec 2014 21:37:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-text-file-to-set-label-expression-in-arcpy/m-p/503555#M39553</guid>
      <dc:creator>PaulCrickard1</dc:creator>
      <dc:date>2014-12-01T21:37:17Z</dc:date>
    </item>
    <item>
      <title>Re: Using a text file to set label expression in ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/using-a-text-file-to-set-label-expression-in-arcpy/m-p/503556#M39554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks, this is very helpful.&amp;nbsp; I think that I am going to give the IronPython method as shot as it appears that it will do exactly what I am looking for.&amp;nbsp; I will let you know how it goes...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Dec 2014 14:17:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-text-file-to-set-label-expression-in-arcpy/m-p/503556#M39554</guid>
      <dc:creator>WesleyAskew</dc:creator>
      <dc:date>2014-12-02T14:17:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using a text file to set label expression in ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/using-a-text-file-to-set-label-expression-in-arcpy/m-p/503557#M39555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I took your advice and went with the IronPython method.&amp;nbsp; I was able to install and reference in Visual Studio with no problem.&amp;nbsp; However, when I run the add-in within ArcMap, I get an error message stating that the ArcPy module does not exist.&amp;nbsp; Will I need to provide a reference to ArcPy in Visual Studio as well?&amp;nbsp; I figured that since the add-in is executed in ArcMap it will use the ArcMap console to run the ArcPy script.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Dec 2014 16:59:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-text-file-to-set-label-expression-in-arcpy/m-p/503557#M39555</guid>
      <dc:creator>WesleyAskew</dc:creator>
      <dc:date>2014-12-03T16:59:51Z</dc:date>
    </item>
    <item>
      <title>Re: Using a text file to set label expression in ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/using-a-text-file-to-set-label-expression-in-arcpy/m-p/503558#M39556</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Do you have more than 1 version of python installed? I have python 2.7 and then another in arcgis subdirectory. My 2.7 does not have arcpy installed. I wonder if maybe it is referencing a python install that is not the ESRI install. if that is the case, you can copy C:\Python27\ArcGIS10.1\Lib\site-packages\Desktop10.1.pth to your other install site lib folder.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Dec 2014 17:09:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-text-file-to-set-label-expression-in-arcpy/m-p/503558#M39556</guid>
      <dc:creator>PaulCrickard</dc:creator>
      <dc:date>2014-12-03T17:09:51Z</dc:date>
    </item>
    <item>
      <title>Re: Using a text file to set label expression in ArcPy</title>
      <link>https://community.esri.com/t5/python-questions/using-a-text-file-to-set-label-expression-in-arcpy/m-p/503559#M39557</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I checked and it appears that only one version of Python is installed on the machine.&amp;nbsp; What's weird is that when I run the script from the add-in, I get the message "No module named arcpy".&amp;nbsp; However, when running it through the ArcMap console, I get the message "No module named numpy".&amp;nbsp; Would this mean that there is a numpy module that is missing?&amp;nbsp; Below is my code, I don't even see a reason why it would use numpy.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import arcpy&lt;/P&gt;&lt;P&gt;import pythonaddins&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;mxd = arcpy.mapping.MapDocument("CURRENT")&lt;/P&gt;&lt;P&gt;lyr = pythonaddins.GetSelectedTOCLayerOrDataFrame()&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if lyr.supports("LABELCLASSES"):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.showLabels = True&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; lyr.labelClasses[0].expression = "[FID]"&lt;/P&gt;&lt;P&gt;arcpy.RefreshActiveView()&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 05 Dec 2014 02:23:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/using-a-text-file-to-set-label-expression-in-arcpy/m-p/503559#M39557</guid>
      <dc:creator>WesleyAskew</dc:creator>
      <dc:date>2014-12-05T02:23:50Z</dc:date>
    </item>
  </channel>
</rss>

