Flask app with ArcGIS, Arcpy does not run

IIRC, ArcGIS maintains it’s own python environment (and used to install it over existing installations, ick). So unless you’re using that environment when you launch/run flask, you’re likely not getting the config/resources loaded that are needed to support Arcpy functions. It’s like trying to load a library installed into a different python virtual environment. You … Read more

Unzip all zipped files in a folder to that same folder using Python 2.7.5

Below is the code that worked for me: import os, zipfile dir_name=”C:\\SomeDirectory” extension = “.zip” os.chdir(dir_name) # change directory from working dir to dir with files for item in os.listdir(dir_name): # loop through items in dir if item.endswith(extension): # check for “.zip” extension file_name = os.path.abspath(item) # get full path of files zip_ref = zipfile.ZipFile(file_name) … Read more

python dict to numpy structured array

You could use np.array(list(result.items()), dtype=dtype): import numpy as np result = {0: 1.1181753789488595, 1: 0.5566080288678394, 2: 0.4718269778030734, 3: 0.48716683119447185, 4: 1.0, 5: 0.1395076201641266, 6: 0.20941558441558442} names = [‘id’,’data’] formats = [‘f8′,’f8’] dtype = dict(names = names, formats=formats) array = np.array(list(result.items()), dtype=dtype) print(repr(array)) yields array([(0.0, 1.1181753789488595), (1.0, 0.5566080288678394), (2.0, 0.4718269778030734), (3.0, 0.48716683119447185), (4.0, 1.0), (5.0, 0.1395076201641266), … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)