ArcGIS cannot run on Apache 2.4 + CGI

714
12
11-14-2017 03:28 AM
NghiepNeoLab
New Contributor

Hi everybody,

I try to use Arcpy on Apache 2.4 and CGI that is basic example. But I can't, It always display error message like "Not signed into Portal".

Although I signed in
I signed in

And then, I check about Licensing
Authorize ArcGIS Pro to work offline

So, ArcGIS configuration is ok.

Now I show you see what Apache configuration

- httpd.conf, I have enabled LoadModule cgi_module modules/mod_cgi.so

- ViltualHost, 

Apache Virtualhost configuration

=> I checked, VirtualHost works well without use Arcpy.

Apache Service is running
Apache 2.4 is running

Python example script

Python script withou arcpy

The result

It works well without arcpy

But When I import Arcpy in my Python script, It has the problem.

The bellowing is apache-cgi-example.py content

#!C:/Program Files/ArcGIS/Pro/bin/Python/envs/arcgispro-py3/python.exe
# coding: utf-8
print("Content-type: text/html\n\n")
print("")
print("<h2>ArcGIS runs on Apache 2.4 + CGI</h2>")

import sys, os
import bottle

import cgitb
cgitb.enable()

realpath = os.path.dirname(os.path.realpath(__file__))
sys.path.append(realpath)

print("<p><b>Project path</b>: {}</p>".format(str(realpath)))

app = bottle.default_app()
app.config.load_config("%s\\app.conf" % realpath)

try:
    print("<p><b>Output path</b>: {}</p>".format(str(app.config['app.output_path'])))

    import arcpy

    # Arcpy can overwrite output
    arcpy.env.overwriteOutput = True

    # set workspace dir
    arcpy.env.workspace = app.config['app.output_path']

    # initiation for volume calculation
    arcpy.CheckOutExtension("3D")
    arcpy.CheckOutExtension("spatial")

except Exception as error:
    print("<p><b>Cannot import Arcpy. Error</b>: {}</p>".format(str(error)))

The problem is "Not signed into Portal"

The page content is 

The problem

Can your please help me?

Thank many help!

Note:

- It has the same problem on IIS environment

- I am using ArcGIS Pro version 1.3 (Python version 3.4.4) 64bit

- I am using Apache 2.4.23  64bit

0 Kudos
12 Replies
GwenRoyakkers
New Contributor III

Why is this posted under "ArcGis Pro SKD" ?

your question isn't related to the .NET SDK. Maybe you should move it to Python?

0 Kudos
NghiepNeoLab
New Contributor

Thank Gwen_roy‌. I moved

0 Kudos
NghiepNeoLab
New Contributor

Thank a lot @Rebecca

0 Kudos
JonathanQuinn
Esri Frequent Contributor

What happens if you import arcpy within the Python window in Pro?

0 Kudos
NghiepNeoLab
New Contributor

If I try to import acrpy in another environment, It works well.

C:\Users\Lab1-Python>python
Python 3.4.4 |Continuum Analytics, Inc.| (default, Feb 16 2016, 09:54:04) [MSC v.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import arcpy
>>>

Also, I run my Python script by python apache-cgi-example.py => It works

C:\Workspace\Arcpy\apache-env>python apache-cgi-example.py
Content-type: text/html

<h2>ArcGIS runs on Apache 2.4 + CGI</h2>
<p><b>Project path</b>: C:\Workspace\Arcpy\apache-env</p>
<p><b>Output path</b>: C:\Workspace\Arcpy\apache-env\Temporary</p>
<p>Arcpy has been imported.</p>

C:\Workspace\Arcpy\apache-env>

It doesn't work on Apache + CGI or IIS + CGI, It looks like Arcpy doesn't work on the environment as Windows service

Finally, If I use arcpy without Apache/IIS, It works

More info

I am using bottle to start my project like web page, almost my function calculate on the raster within big data and a lot user connect to request data. For example: I calculate CutFill of surface.

=> Sometime is suspended.

So, I need to set up a web server for my project. My script can run on Apache/Nginx, IIS or whatever.

----

I also have the problem when try to use Arcpy on Apache + mod_wsgi but I cannot use CutFill tool

https://community.esri.com/message/728902-arcgis-pro-has-stopped-working-when-using-cutfill-tool?sr=...

I really need any help to resolve it. 

so If someone has another way please help me. 

Thank a lot.

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

You mention ArcGIS pro and arcpy in the same context.  I am under the impression that arcpy for pro is tied to the anaconda distribution.  Did you have evidence that it works elsewhere?  

Also, version 1.3 is outdated and I see no reference in the What's new section going back that changes this.  Have you field a support request?  

0 Kudos
NghiepNeoLab
New Contributor

Hi Dan Patterson

Yeah, I knew version 1.3 is very old but my customer is using that version. I cannot request they upgrade.

So I share to you about arcpy works on another environment via video

And I also use PyCharm to run my Python script. And It works well

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

sounds like a Support call... nothing in there helped me point you in the right direction.,.. sorry

0 Kudos