S Andrew
S Andrew

Reputation: 7228

How to add directory to PATH in azure python app service

I have a python azure app running fine. I have installed cmake in it using

python -m pip install cmake

This was installed fine but I also got the below warning:

WARNING: The scripts cmake.exe, cpack.exe and ctest.exe are installed in 'D:\home\python364x64\Scripts'
which is not on PATH. Consider adding this directory to PATH

enter image description here

Because of above warning, if I am installing any other package which needs cmake to be installed, I am getting error that cmake not found.

I typed PATH and it showed me a list of all the values. How can I add the directory D:\home\python364x64\Scripts in PATH. Please help. Thanks

Upvotes: 0

Views: 1263

Answers (1)

George Chen
George Chen

Reputation: 14334

There is an official tutorial:How to set up a Python environment on Azure App Service.

Configure the HttpPlatform handler

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
    <handlers>
      <add name="PythonHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
    </handlers>
    <httpPlatform processPath="D:\home\Python361x64\python.exe"
                  arguments="D:\home\site\wwwroot\runserver.py --port %HTTP_PLATFORM_PORT%"
                  stdoutLogEnabled="true"
                  stdoutLogFile="D:\home\LogFiles\python.log"
                  startupTimeLimit="60"
                  processesPerApplication="16">
      <environmentVariables>
        <environmentVariable name="SERVER_PORT" value="%HTTP_PLATFORM_PORT%" />
      </environmentVariables>
    </httpPlatform>
  </system.webServer>
</configuration>

Configure the FastCGI handler

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <appSettings>
    <add key="PYTHONPATH" value="D:\home\site\wwwroot"/>
    <!-- The handler here is specific to Bottle; other frameworks vary. -->
    <add key="WSGI_HANDLER" value="app.wsgi_app()"/>
    <add key="WSGI_LOG" value="D:\home\LogFiles\wfastcgi.log"/>
  </appSettings>
  <system.webServer>
    <handlers>
      <add name="PythonHandler" path="*" verb="*" modules="FastCgiModule"
           scriptProcessor="D:\home\Python361x64\python.exe|D:\home\Python361x64\wfastcgi.py"
           resourceType="Unspecified" requireAccess="Script"/>
    </handlers>
  </system.webServer>
</configuration>

Here is a FastCGI handler sample with application setting.

enter image description here

And there is another way with applicationHost.xdt file, you could refer to here:Xdt transform samples. To add a folder to PATH, below is a sample.

<?xml version="1.0"?> 
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform"> 
  <system.webServer> 
    <runtime xdt:Transform="InsertIfMissing">
      <environmentVariables xdt:Transform="InsertIfMissing">
        <add name="FOO" value="BAR" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing" />    
        <add name="PATH" value="%PATH%;%HOME%\FolderOnPath" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing" />    
      </environmentVariables>
    </runtime> 
  </system.webServer> 
</configuration> 

Upvotes: 1

Related Questions