Subscribe to this thread
Home - General / All posts - Calling Python modules from Manifold IronPython
artlembo


3,477 post(s)
#31-Jul-26 17:26

I’ve been making really good use of geopy (thing like censusgeocoder) in both a standard IDLE interface, and also integrating these modules with Arcpy.

Does anyone have the steps necessary to use ironpython inside of manifold to import modules like censusgeocode?

For ArcGIS, I do a pip install censusgeocoder into the site-packages folder in my ArcGIS Pro path.

So what I’m trying to figure out is how to install the package with IronPython, and where the package should be installed. Do we need a site–packages folder inside Manifold’s extra folder? I’ve go IronPython 3.7 and copied the .dlls into the extras folder.

rk
685 post(s)
#01-Aug-26 07:26

Yes. I got censusgeocode running with IronPython.

I built the current mainbranch of https://github.com/IronLanguages/ironpython3

(it says v3.4.2 but that's old release number)

I installed it to C:\Apps\ipy342net4\

just this fails:

ipy -m pip install censusgeocode

but apparently some deps are optional.

C:\Apps\ipy342net4\Enter-IronPythonEnvironment.ps1

ipy -m ensurepip

ipy -m pip install --no-deps censusgeocode requests_toolbelt six

ipy.exe

>>> # IronPython REPL

import censusgeocode as cg

cg.coordinates(x=-76, y=41)

# good response here!

There are often errors if we try to run some python package with IronPython, because if some of its dependencies are CPython C extensions then IronPython won't be able to run them.

I also built current 3.6 branch of https://github.com/IronLanguages/ironpython3.

With 3.6 ipy -m pip install censusgeocode(without r) succeeds. But on usage errors appear.

Also worth considering:

Claude Opus 5 proposed

The practical path is to skip the requests-based stack entirely and call the Census Geocoder API directly — it's just plain HTTP GET with query-string params returning JSON, so .NET's own HttpClient handles it fine without touching any of the Python HTTP layers:

#python

import clr

clr.AddReference("System.Net.Http")

from System.Net.Http import HttpClient

from System import Uri

import json

BASE_URL = "https://geocoding.geo.census.gov/geocoder/"

_client = HttpClient()

def geocode_oneline(address, returntype="locations", benchmark="Public_AR_Current"):

    url = "{0}{1}/onelineaddress?address={2}&benchmark={3}&format=json".format(

        BASE_URL, returntype, Uri.EscapeDataString(address), benchmark)

    response = _client.GetAsync(url).Result

    response.EnsureSuccessStatusCode()

    text = response.Content.ReadAsStringAsync().Result

    return json.loads(text)

result = geocode_oneline("1600 Pennsylvania Avenue, Washington, DC")

match = result["result"]["addressMatches"][0]

lon = match["coordinates"]["x"]

lat = match["coordinates"]["y"]

print(lat, lon)

rk
685 post(s)
#01-Aug-26 08:37

I share the self-built IronPython and instructions in this OneDrive folder. (You must trust that not me nor my machine are corrupt)

https://1drv.ms/f/c/bc53d61b0ca53f95/IgAPOnh5OnphTbCsuFPig2QTASC5lBzsQ46PnNNR-ifzueM?e=griZeP

Actually, you can use the official 3.4.2 release from

https://github.com/IronLanguages/ironpython3/releases/download/v3.4.2/IronPython.3.4.2.zip

Works also!

Attachments:
censusgeogode-proof.png

artlembo


3,477 post(s)
#01-Aug-26 14:39

Thanks, Rivo. I figured you would be the person to respond with a good answer,

artlembo


3,477 post(s)
#01-Aug-26 16:45

Rivo,

you description worked like a charm! Thanks. For those lurking, and for myself in the future, it really only requires the following steps (after having installed IronPython on your computer):

Install Census Geocode:

from inside Command Prompt in the IronPython install directory:

ipy -m pip install requests

ipy -m pip install --no-deps censusgeocode requests_toolbelt six

Script:

inside a Manifold IronPython script:

def Main():

 import sys

 sys.path.extend(['C:\\Program Files\\IronPython 3.4\\Lib','C:\\Program Files\\IronPython 3.4\\Lib\\site-packages'])

 import censusgeocode as cg

 result = cg.onelineaddress("1600 Pennsylvania Ave NW, Washington, DC")

 coordinates = result[0]['coordinates']

 Manifold.Application.Log(str(coordinates))

Manifold User Community Use Agreement Copyright (C) 2007-2021 Manifold Software Limited. All rights reserved.