[Python.NET] import failing help needed
Mark A Gregory <[email protected]> Sun, 12 Feb 2023 03:03:18 +0000
| Newsgroups | gmane.comp.python.dotnet |
|---|---|
| Message-ID | <ME2P282MB222861D61C463289E0DB3A90FADC9@ME2P282MB2228.AUSP282.PROD.OUTLOOK.COM> |
--===============3618584045358491726==
Content-Language: en-US
Content-Type: multipart/alternative;
boundary="_000_ME2P282MB222861D61C463289E0DB3A90FADC9ME2P282MB2228AUSP_"
--_000_ME2P282MB222861D61C463289E0DB3A90FADC9ME2P282MB2228AUSP_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
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\Pytho=
n311\python311.dll";
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)
|| RuntimeInformation.IsOSPlatform(OSPlatform.FreeBSD))
{
return "libpython3.11.so";
}
return null;
}
string pythonDll =3D GetPythonLib();
Runtime.PythonDLL =3D pythonDll;
Environment.SetEnvironmentVariable("PYTHONNET_PYDLL", pythonDll);
PythonEngine.Initialize();
_gilState =3D Py.GIL();
using (Py.GIL())
{
dynamic pyproj =3D Py.Import("pyproj");
_geod =3D pyproj.Geod(ellps: "WGS84");
}
}
Regards
Mark Gregory
--_000_ME2P282MB222861D61C463289E0DB3A90FADC9ME2P282MB2228AUSP_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
font-size:11.0pt;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri",sans-serif;
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3D"EN-AU" link=3D"#0563C1" vlink=3D"#954F72" style=3D"word-wrap:=
break-word">
<div class=3D"WordSection1">
<p class=3D"MsoNormal">Windows 11. Visual Studio 2022. Python311 install an=
d working using VSCode. Pythonnet installed using VS 2022 nuget and pip3 in=
command prompt<o:p></o:p></p>
<p class=3D"MsoNormal">I have this code and it is failing at import pyproj =
– error is no _socket<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">Help appreciated<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal">public AzimuthBoundingBoxCalculator()<o:p></o:p></p>
<p class=3D"MsoNormal"> {<o:p></o:p></p>
<p class=3D"MsoNormal"> string? G=
etPythonLib()<o:p></o:p></p>
<p class=3D"MsoNormal"> {<o:p></o=
:p></p>
<p class=3D"MsoNormal"> &nbs=
p; if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))<o:p></o=
:p></p>
<p class=3D"MsoNormal"> &nbs=
p; {<o:p></o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; return "/Library/Frameworks/Pyt=
hon.framework/Versions/3.11/lib/libpython3.11.dylib";<o:p></o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; }<o:p></o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))<o:p=
></o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; {<o:p></o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; return @"C:\Users\basic\AppData=
\Local\Programs\Python\Python311\python311.dll";<o:p></o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; }<o:p></o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)<o:p></=
o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; || RuntimeInformation.IsOSPlatform(O=
SPlatform.FreeBSD))<o:p></o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; {<o:p></o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; return "libpython3.11.so";=
<o:p></o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; }<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal"> &nbs=
p; return null;<o:p></o:p></p>
<p class=3D"MsoNormal"> }<o:p></o=
:p></p>
<p class=3D"MsoNormal"> string py=
thonDll =3D GetPythonLib();<o:p></o:p></p>
<p class=3D"MsoNormal"> Runtime.P=
ythonDLL =3D pythonDll;<o:p></o:p></p>
<p class=3D"MsoNormal"> Environme=
nt.SetEnvironmentVariable("PYTHONNET_PYDLL", pythonDll);<o:p></o:=
p></p>
<p class=3D"MsoNormal"> PythonEng=
ine.Initialize();<o:p></o:p></p>
<p class=3D"MsoNormal"> _gilState=
=3D Py.GIL();<o:p></o:p></p>
<p class=3D"MsoNormal"> using (Py=
.GIL())<o:p></o:p></p>
<p class=3D"MsoNormal"> {<o:p></o=
:p></p>
<p class=3D"MsoNormal"> &nbs=
p; dynamic pyproj =3D Py.Import("pyproj");<o:p></o:p>=
</p>
<p class=3D"MsoNormal"> &nbs=
p; _geod =3D pyproj.Geod(ellps: "WGS84");<o:p></o:p><=
/p>
<p class=3D"MsoNormal"> }<o:p></o=
:p></p>
<p class=3D"MsoNormal"> }<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
<p class=3D"MsoNormal"><span style=3D"mso-fareast-language:EN-AU">Regards<o=
:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"mso-fareast-language:EN-AU">Mark Greg=
ory<o:p></o:p></span></p>
<p class=3D"MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>
--_000_ME2P282MB222861D61C463289E0DB3A90FADC9ME2P282MB2228AUSP_--
--===============3618584045358491726==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Python.NET mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/pythonnet.python.org/
Member address: [email protected]
--===============3618584045358491726==--