Windows 11. Visual Studio 2022. Python311 install and working using VSCode. Pythonnet installed using VS 2022 nuget and pip3 in command prompt

I have this code and it is failing at import pyproj – error is no _socket

 

Help appreciated

 

public AzimuthBoundingBoxCalculator()

    {

        string? GetPythonLib()

        {

            if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))

            {

                return "/Library/Frameworks/Python.framework/Versions/3.11/lib/libpython3.11.dylib";

            }

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))

            {

                return @"C:\Users\basic\AppData\Local\Programs\Python\Python311\python311.dll";

            }

            if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)

                || RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD))

            {

                return "libpython3.11.so";

            }

 

            return null;

        }

        string pythonDll = GetPythonLib();

        Runtime.PythonDLL = pythonDll;

        Environment.SetEnvironmentVariable("PYTHONNET_PYDLL", pythonDll);

        PythonEngine.Initialize();

        _gilState = Py.GIL();

        using (Py.GIL())

        {

            dynamic pyproj = Py.Import("pyproj");

            _geod = pyproj.Geod(ellps: "WGS84");

        }

    }

 

 

Regards

Mark Gregory