[Python.NET] Python.NET and VS2001/.NET 4.0

Tribble, Brett btribble at ea.com
Tue Jan 18 19:08:50 CET 2011

Thanks Biduik,

I will need this in a few short weeks.

From: pythondotnet-bounces+btribble=ea.com at python.org [mailto:pythondotnet-bounces+btribble=ea.com at python.org] On Behalf Of Oleksii Bidiuk
Sent: Monday, January 17, 2011 8:06 AM
To: pythondotnet at python.org
Subject: [Python.NET] Python.NET and VS2001/.NET 4.0

Hi All,

I hope this will help some people like me searching for an answer. Several steps were mentioned by other people as well, but I haven't seen a step-by-step guide. It is not my intention to duplicate other posts in that sense, but rather have all-in-one post.

Here is how I've got VS2010 and .NET 4.0 working with the revision 119 of the Python.NET having Python 2.6 installed. Note that the latest trunk (revision 122) gave me some problems, so I have basically reverted changes to match 119 for the time being.

1. Get the sources (tarball from sourceforge or directly from SVN)
2. Open the pythonnet.sln with VS2010 and convert to 2010 format (will happen automagically)
3. Change the target framework to 4. Follow the following step for EACH project
    3.1. Right-click on the project name and select "Properties"
    3.2. Select the "Application" tab on the left (if not selected yet)
    3.3. Change the "Target framework" to ".NET Framework 4"
4. Open the clrmodule.il<http://clrmodule.il> and change the lines with the version number in the following piece of code

.assembly extern mscorlib
     .publickeytoken = (B7 7A 5C 56 19 34 E0 89 )
     .ver 2:0:0:0

to have

     .ver 4:0:0:0

5. Open the buildclrmodule.bat and change the

%windir%\Microsoft.NET\Framework\v2.0.50727\ilasm /nologo /quiet /dll %ILASM_EXTRA_ARGS% /include=%INCLUDE_PATH% /output=%OUTPUT_PATH% %INPUT_PATH%


%windir%\Microsoft.NET\Framework\v4.0.30319\ilasm /nologo /quiet /dll %ILASM_EXTRA_ARGS% /include=%INCLUDE_PATH% /output=%OUTPUT_PATH% %INPUT_PATH%

5. Recompile the whole solution, ignore the deprecation warnings.

Now you have all necessary files under the pythonnet folder where you have the sources. You need clr.pyd, python.exe and Python.Runtime.dll.

Run the newly comiled python.exe
Type the following

>>> import System >>> print System.Environment.Version 4.0.30319.1

The last line proves that you're using hte 4.0 runtime. The precomiled binaries available from Sourceforge would show

This is also posted with somewhat better formatting under blog.bidiuk.com/2011/01/python-net-and-vs2010-net-4/<http://blog.bidiuk.com/2011/01/python-net-and-vs2010-net-4/>

Comments and suggestions are welcome!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pythondotnet/attachments/20110118/6c572f50/attachment.html>

More information about the PythonDotNet mailing list