<?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: Executing Hazus Software through Python Script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/executing-hazus-software-through-python-script/m-p/236533#M18407</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello Meredith,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You actually pretty close. You were right not to import arcpy. As a good rule of thumb, you should only import a module if you need it. Since you are only using the &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;os&lt;/SPAN&gt;&lt;SPAN&gt; module, you should only import the &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;os&lt;/SPAN&gt;&lt;SPAN&gt; module.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, python reads "\" as a special character (for example "/n" is new line). This means you have to take special actions when inputting a path. There are several ways to do this. One is replacing "/" with "//" or "\" (python reads "\\" or "/" as a "\"). You can also add a 'r' in front of the string to tell python you are inputting a path.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Last thing, if you want the start a program, the command you are likely looking for is &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;os.system()&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import os os.system(r'"C:\Program Files (x86)\Hazus-MH\BIN\Hazusp.exe"')&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Edit: you need double quotes in single quote just for os.system to run the command properly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me know if that was what you were looking for!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 11 Mar 2014 17:43:56 GMT</pubDate>
    <dc:creator>JoshuaChisholm</dc:creator>
    <dc:date>2014-03-11T17:43:56Z</dc:date>
    <item>
      <title>Executing Hazus Software through Python Script</title>
      <link>https://community.esri.com/t5/python-questions/executing-hazus-software-through-python-script/m-p/236532#M18406</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I am trying to write a script that runs Hazus Software but am having a hard time getting started and keep getting an invalid syntax error.&amp;nbsp; The problem is that I'm not sure if I should also be importing the arcpy module as well since it is linked to ArcGIS or if I should just import os/subprocess.&amp;nbsp; The other thing that keeps throwing me off is I keep reading numerous solutions to executing a program in general so I don't even know what I should be importing.&amp;nbsp; Here is what I have right now:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;#import os import os os.path.abspath('C:\Program Files (x86)\Hazus-MH\BIN\Hazusp.exe')&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm still learning a lot when it comes to python so if anybody has an idea how I should start this I would greatly appreciate the input.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Mar 2014 17:30:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/executing-hazus-software-through-python-script/m-p/236532#M18406</guid>
      <dc:creator>MeredithGreen</dc:creator>
      <dc:date>2014-03-11T17:30:04Z</dc:date>
    </item>
    <item>
      <title>Re: Executing Hazus Software through Python Script</title>
      <link>https://community.esri.com/t5/python-questions/executing-hazus-software-through-python-script/m-p/236533#M18407</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello Meredith,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;You actually pretty close. You were right not to import arcpy. As a good rule of thumb, you should only import a module if you need it. Since you are only using the &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;os&lt;/SPAN&gt;&lt;SPAN&gt; module, you should only import the &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;os&lt;/SPAN&gt;&lt;SPAN&gt; module.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also, python reads "\" as a special character (for example "/n" is new line). This means you have to take special actions when inputting a path. There are several ways to do this. One is replacing "/" with "//" or "\" (python reads "\\" or "/" as a "\"). You can also add a 'r' in front of the string to tell python you are inputting a path.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Last thing, if you want the start a program, the command you are likely looking for is &lt;/SPAN&gt;&lt;SPAN style="font-style:italic;"&gt;os.system()&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;import os os.system(r'"C:\Program Files (x86)\Hazus-MH\BIN\Hazusp.exe"')&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Edit: you need double quotes in single quote just for os.system to run the command properly.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me know if that was what you were looking for!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Mar 2014 17:43:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/executing-hazus-software-through-python-script/m-p/236533#M18407</guid>
      <dc:creator>JoshuaChisholm</dc:creator>
      <dc:date>2014-03-11T17:43:56Z</dc:date>
    </item>
    <item>
      <title>Re: Executing Hazus Software through Python Script</title>
      <link>https://community.esri.com/t5/python-questions/executing-hazus-software-through-python-script/m-p/236534#M18408</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the speedy response.&amp;nbsp; After making a couple of tweaks this is the new script as of now:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#import os
import os
os.system(r'"C:\Program Files (x86)\Hazus-MH\BIN\Hazusp.exe"')&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;But I still keep getting an invalid syntax error.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:55:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/executing-hazus-software-through-python-script/m-p/236534#M18408</guid>
      <dc:creator>MeredithGreen</dc:creator>
      <dc:date>2021-12-11T11:55:48Z</dc:date>
    </item>
    <item>
      <title>Re: Executing Hazus Software through Python Script</title>
      <link>https://community.esri.com/t5/python-questions/executing-hazus-software-through-python-script/m-p/236535#M18409</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;For some reason the invalid syntax error is highlighting the 6 in Python 2.6.5.&amp;nbsp; Would anyone know why?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Python 2.&lt;STRONG&gt;6&lt;/STRONG&gt;.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.

&amp;nbsp;&amp;nbsp;&amp;nbsp; ****************************************************************
&amp;nbsp;&amp;nbsp;&amp;nbsp; Personal firewall software may warn about the connection IDLE
&amp;nbsp;&amp;nbsp;&amp;nbsp; makes to its subprocess using this computer's internal loopback
&amp;nbsp;&amp;nbsp;&amp;nbsp; interface.&amp;nbsp; This connection is not visible on any external
&amp;nbsp;&amp;nbsp;&amp;nbsp; interface and no data is sent to or received from the Internet.
&amp;nbsp;&amp;nbsp;&amp;nbsp; ****************************************************************
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
IDLE 2.6.5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;gt;&amp;gt;&amp;gt; 
#import os
import os
os.system(r'"C:\Program Files (x86)\Hazus-MH\BIN\Hazusp.exe"')&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The Python 2.&lt;/SPAN&gt;&lt;STRONG&gt;6&lt;/STRONG&gt;&lt;SPAN&gt;.5 at the front is what keeps getting the invalid syntax error.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:55:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/executing-hazus-software-through-python-script/m-p/236535#M18409</guid>
      <dc:creator>MeredithGreen</dc:creator>
      <dc:date>2021-12-11T11:55:51Z</dc:date>
    </item>
    <item>
      <title>Re: Executing Hazus Software through Python Script</title>
      <link>https://community.esri.com/t5/python-questions/executing-hazus-software-through-python-script/m-p/236536#M18410</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;This may be a simple fix.&amp;nbsp; It looks like you have too many quotes in your system command.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Try replacing &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;os.system(r'"C:\Program Files (x86)\Hazus-MH\BIN\Hazusp.exe"')&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;with &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_macro_code jive_text_macro"&gt;os.system(r"C:\Program Files (x86)\Hazus-MH\BIN\Hazusp.exe")&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;All I did there was remove the extra sets of quotes.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Mar 2014 18:55:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/executing-hazus-software-through-python-script/m-p/236536#M18410</guid>
      <dc:creator>MattEiben</dc:creator>
      <dc:date>2014-03-11T18:55:41Z</dc:date>
    </item>
    <item>
      <title>Re: Executing Hazus Software through Python Script</title>
      <link>https://community.esri.com/t5/python-questions/executing-hazus-software-through-python-script/m-p/236537#M18411</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hello Meredith and Matt,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Let me know if Matt's solution works out. I've found that if you are using &lt;/SPAN&gt;&lt;SPAN style="font-style: italic; text-decoration: underline;"&gt;os.system()&lt;/SPAN&gt;&lt;SPAN&gt; and running a file that has spaces in the path you need another set of quotes or windows will try to execute "C:\Program" as a command with the arguments "Files" and "(x86)\Hazus-MH\BIN\Hazusp.exe".&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm not sure exactly why you're getting a syntax error. We must be missing something simple.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you running python in command line (one line at a time), make sure you enter only one line at a time (pressing enter to run each line).&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Also note that the # character denote a comment. Python will ignore anything on the line after the # character. So &lt;/SPAN&gt;&lt;SPAN style="font-style: italic; text-decoration: underline;"&gt;#import os&lt;/SPAN&gt;&lt;SPAN&gt; is being ignored and &lt;/SPAN&gt;&lt;SPAN style="font-style: italic; text-decoration: underline;"&gt;import os&lt;/SPAN&gt;&lt;SPAN&gt; will actually import the module os.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Sorry if I'm not being clear or if I'm over explaining anything. I'm just trying to make sure we're not missing anything obvious.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Mar 2014 20:23:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/executing-hazus-software-through-python-script/m-p/236537#M18411</guid>
      <dc:creator>JoshuaChisholm</dc:creator>
      <dc:date>2014-03-11T20:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: Executing Hazus Software through Python Script</title>
      <link>https://community.esri.com/t5/python-questions/executing-hazus-software-through-python-script/m-p/236538#M18412</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;For some reason the invalid syntax error is highlighting the 6 in Python 2.6.5.&amp;nbsp; Would anyone know why?&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;Python 2.&lt;STRONG&gt;6&lt;/STRONG&gt;.5 (r265:79096, Mar 19 2010, 21:48:26) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.

&amp;nbsp;&amp;nbsp;&amp;nbsp; ****************************************************************
&amp;nbsp;&amp;nbsp;&amp;nbsp; Personal firewall software may warn about the connection IDLE
&amp;nbsp;&amp;nbsp;&amp;nbsp; makes to its subprocess using this computer's internal loopback
&amp;nbsp;&amp;nbsp;&amp;nbsp; interface.&amp;nbsp; This connection is not visible on any external
&amp;nbsp;&amp;nbsp;&amp;nbsp; interface and no data is sent to or received from the Internet.
&amp;nbsp;&amp;nbsp;&amp;nbsp; ****************************************************************
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
IDLE 2.6.5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&amp;gt;&amp;gt;&amp;gt; 
#import os
import os
os.system(r'"C:\Program Files (x86)\Hazus-MH\BIN\Hazusp.exe"')&lt;/PRE&gt;&lt;BR /&gt;&lt;BR /&gt;The Python 2.&lt;STRONG&gt;6&lt;/STRONG&gt;.5 at the front is what keeps getting the invalid syntax error.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The additional text above the script is automatically included when I open up the python shell to write.&amp;nbsp; I decided to just delete all of it and it worked!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;#import os
import os
os.system(r'"C:\Program Files (x86)\Hazus-MH\BIN\Hazusp.exe"')&lt;/PRE&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Is the correct code and it did open up the hazus program.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks for all of the help!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sat, 11 Dec 2021 11:55:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/executing-hazus-software-through-python-script/m-p/236538#M18412</guid>
      <dc:creator>MeredithGreen</dc:creator>
      <dc:date>2021-12-11T11:55:53Z</dc:date>
    </item>
    <item>
      <title>Re: Executing Hazus Software through Python Script</title>
      <link>https://community.esri.com/t5/python-questions/executing-hazus-software-through-python-script/m-p/236539#M18413</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Oh, sorry, I thought that was you typing into the console, not the actual script itself. Thanks for the update and I'm happy you figured it out!&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Mar 2014 12:17:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/executing-hazus-software-through-python-script/m-p/236539#M18413</guid>
      <dc:creator>JoshuaChisholm</dc:creator>
      <dc:date>2014-03-12T12:17:23Z</dc:date>
    </item>
  </channel>
</rss>

