I am unable to use arcpy with my Flask application. archook and arcpy seem to get imported successfully, but when I call an arcpy method I get this:
Object: Tool or environment <FeatureClassToShapefile_conversion> not found
or sometimes the Python.exe crashes altogether.
I have no issues running any of the functions in data_processes.py on its own, but when they are called from Flask I get those errors. Any suggestions on what the problem could be is much appreciated.
flaskapp.py:
from data_processes import list_esri_data, to_shapefile
from flask import Flask, render_template, request, send_file, jsonify, url_for
import os
app = Flask(__name__)
@app.route('/')
def home():
return render_template('pages/home.html')
@app.route('/data/all')
def data_list():
return jsonify(list_esri_data())
@app.route('/data/shapefile')
def download_shapefile():
d = to_shapefile(request.args.get('dataset'))
return send_file(filename_or_fp=d)
@app.context_processor
def override_url_for():
return dict(url_for=dated_url_for)
def dated_url_for(endpoint, **values):
if endpoint == 'static':
filename = values.get('filename', None)
if filename:
file_path = os.path.join(app.root_path,
endpoint, filename)
values['q'] = int(os.stat(file_path).st_mtime)
return url_for(endpoint, **values)
if __name__ == '__main__':
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port, debug=True)
I am unable to use arcpy with my Flask application.
archook
andarcpy
seem to get imported successfully, but when I call anarcpy
method I get this:Object: Tool or environment <FeatureClassToShapefile_conversion> not found
or sometimes the Python.exe crashes altogether.I have no issues running any of the functions in
data_processes.py
on its own, but when they are called from Flask I get those errors. Any suggestions on what the problem could be is much appreciated.flaskapp.py:
data_processess.py: This does the arcpy work