<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<!--[if !mso]><style>v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style><![endif]--><style><!--
/* Font Definitions */
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"\@SimSun";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
span.E-MailFormatvorlage17
        {mso-style-type:personal-reply;
        font-family:"Arial","sans-serif";
        color:windowtext;
        font-weight:normal;
        font-style:normal;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="DE" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif"">Hi, Lin,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif"">You need to provide the IronPython standard library to your application. The IronPython standard library consists of two parts: The IronPython.modules.dll (which
 roughly represents the "native" part of the cPython standard library) and a Directory full of python files (which is nearly identical to the python part of the cPython standard library).
<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif"">It seems you already found the first part, and (as a hack) used the cPython version of the second part.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif"">I see three options:<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif"">1) Ship the second part of the standard Library with your application as a directory tree. You just need to add the directory to sys.path (can be done by python
 code, or by the hosting .NET code). This way is the most similar and compatible one compared to cPython, and e. G. also implemented by CODESYS.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif"">2) Using ZipImport: Newer versions of IronPython support ZipImport, so you could just zip the directory tree together, and add the zip file to sys.path.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif"">3) You can compile the python files to a .NET Assembly (.dll file) using the "pyc.py" script (which should be included in recent ironpython packages).<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif"">I've never done 2 and 3 myself, but as far as I know, others have with success.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif"">You should use the python files which are shipped with the corresponding IronPython version instead of the cPython ones, as they contain some compatibility patches
 and fixes. The IronPython developers intend to unify the standard library with the cPython one, but they're not there yet.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif""><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif";color:black">Best regards<br>
<br>
Markus Schaber</span><span lang="EN-US"><br>
<br>
</span><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#636363">CODESYS<sup>®</sup></span></b><span lang="EN-US">
</span><span lang="EN-US" style="font-size:8.0pt;font-family:"Arial","sans-serif";color:#B1B2B3">a trademark of 3S-Smart Software Solutions GmbH</span><span lang="EN-US">
<br>
</span><b><span lang="EN-US" style="font-size:2.0pt;font-family:"Arial","sans-serif";color:#636363"><br>
</span></b><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#636363">Inspiring Automation Solutions
</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#636363"><o:p></o:p></span></p>
<div class="MsoNormal"><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#636363">
<hr size="1" width="636" style="width:477.0pt" noshade="" style="color:#636363" align="left">
</span></div>
<p class="MsoNormal"><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#636363">3S-Smart Software Solutions GmbH
<br>
Dipl.-Inf. Markus Schaber | Product Development Core Technology <br>
Memminger Str. 151 | 87439 Kempten | Germany <br>
Tel. +49-831-54031-979 | Fax +49-831-54031-50 <br>
<br>
E-Mail: </span><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#636363"><a href="mailto:m.schaber@codesys.com"><span lang="EN-US" style="color:#E3000F;text-decoration:none">m.schaber@codesys.com</span></a></span><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#636363">
 | Web: </span><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#636363"><a href="http://www.codesys.com"><span lang="EN-US" style="color:#E3000F;text-decoration:none">codesys.com</span></a></span><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#636363">
 | CODESYS store: </span><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#636363"><a href="http://store.codesys.com"><span lang="EN-US" style="color:#E3000F;text-decoration:none">store.codesys.com</span></a></span><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#636363">
<br>
CODESYS forum: </span><span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#636363"><a href="http://forum.codesys.com"><span lang="EN-US" style="color:#E3000F;text-decoration:none">forum.codesys.com</span></a></span><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#636363">
<br>
<br>
</span><i><span lang="EN-US" style="font-size:8.0pt;font-family:"Arial","sans-serif";color:#636363">Managing Directors: Dipl.Inf. Dieter Hess, Dipl.Inf. Manfred Werner</span></i><span lang="EN-US" style="font-size:8.0pt;font-family:"Arial","sans-serif";color:#636363">
 | <i>Trade register: Kempten HRB 6186</i> | <i>Tax ID No.: DE 167014915</i></span><b><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif";color:#636363">
</span></b><span lang="EN-US" style="font-size:10.0pt;font-family:"Arial","sans-serif""><o:p></o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0cm 0cm 0cm 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">Von:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Ironpython-users [mailto:ironpython-users-bounces+m.schaber=codesys.com@python.org]
<b>Im Auftrag von </b>Lin LIU<br>
<b>Gesendet:</b> Donnerstag, 3. April 2014 17:26<br>
<b>An:</b> ironpython-users@python.org<br>
<b>Betreff:</b> [Ironpython-users] How to get lib json in ironpython<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Hello everyone,<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">    I'm a newbie of IronPython and I'm a python user since 3 years. Actually, I work on a .NET based project in which I use IronPython to call the CS libs. I encountered a problem when I wanted get lib Json in ironpython and then I put
 the following codes in the beginning of the script and it works.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><b><span style="color:blue">import</span></b> sys<br>
sys.path.<b><span style="color:blue">append</span></b>(<span style="color:red">"C:\Program Files\IronPython 2.7\Lib"</span>)<br>
<b><span style="color:blue">import</span></b> json<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">But this solution impose the installation of ironpython.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Otherwise, putting the IronPython.dll, IronPython.Module.dll in my app directory can also help me to get some python libs, ex: re. But this doesn"t work to get lib json.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I wonder if anyone of you has the same experience as mine and already has found a DLL which contains json.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">I hear that using .NET libs in script python can also get json, but I've no idea which lib to use and how to use it. Anyone can help me. Thanks a lot.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Best regards,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Lin <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</div>
</body>
</html>