How to compile Python for .Net in VS2010 and .NET 4?

Hello, I downloaded from SVN, and tried to compile it in VS2010 with Windows 2008 R2. However, it requires Mono.Unix reference in error message. so I installed mono(mono-2.10.9-gtksharp-2.12.11-win32-0.exe from http://www.go-mono.com/mono-downloads/download.html. And added Mono.Posix.dll as reference, and compiled again, got error. FYI, I selected build option as DebugWin/x86. ------------------------------------------------------------------------------ The command "call "buildclrmodule.bat" x86 "c:\cvs\pythonnet\src\runtime\" "c:\cvs\pythonnet\src\runtime\bin\x86\release\clr.pyd" copy "c:\cvs\pythonnet\src\runtime\bin\x86\Release\Python.Runtime.dll" "c:\cvs\pythonnet\" copy "c:\cvs\pythonnet\src\runtime\bin\x86\Release\*.pdb" "c:\cvs\pythonnet" copy "c:\cvs\pythonnet\src\runtime\bin\x86\Release\clr.pyd" "c:\cvs\pythonnet" " exited with code 1." ------------------------------------------------------------------------------ Any idea? Thanks, spark. [image: Inline image 1]

As I opened the file 'buildclrmodule.bat' it has comment like :: Call with buildclrmodule.bat <AnyCPU|x64> <INPUT_DIRECTORY> <OUTPUT_PATH> I added to support x86 below. and compiled successfully. However, when I run nPython.exe C:\CVS\Pythonnet>npython Unhandled Exception: System.EntryPointNotFoundException: Unable to find an entry point named 'PyUnicodeUCS4_FromUnicode' in DLL 'python27'. at Python.Runtime.Runtime.PyUnicode_FromUnicode(String s, Int32 size) at Python.Runtime.Runtime.Initialize() in c:\CVS\Pythonnet\src\runtime\runtime.cs:line 101 at Python.Runtime.PythonEngine.Initialize() in c:\CVS\Pythonnet\src\runtime\pythonengine.cs:line 117 at Python.Runtime.PythonConsole.Main(String[] args) in c:\CVS\Pythonnet\src\console\pythonconsole.cs:line 22 C:\CVS\Pythonnet> What do I need to run without above message? Thank you, Spark. ---------------------------------------------------- @echo off set TARGET_PLATFORM=%1 set INPUT_DIRECTORY=%~2 set INPUT_PATH="%INPUT_DIRECTORY%\clrmodule.il" set OUTPUT_PATH=%3 if %TARGET_PLATFORM%==AnyCPU goto SETUP32 *if %TARGET_PLATFORM%==x86 goto SETUP32* if %TARGET_PLATFORM%==x64 goto SETUP64 goto ERROR_BAD_PLATFORM :SETUP32 set INCLUDE_PATH="%INPUT_DIRECTORY%\x86" goto BUILD_CLR_MODULE :SETUP64 set INCLUDE_PATH="%INPUT_DIRECTORY%\x64" set ILASM_EXTRA_ARGS=/pe64 /x64 goto BUILD_CLR_MODULE :ERROR_BAD_PLATFORM echo Unknown target platform: %TARGET_PLATFORM% exit /b 1 :ERROR_MISSING_INPUT echo Can't find input file: %INPUT_PATH% exit /b 1 :BUILD_CLR_MODULE if not exist %INPUT_PATH% goto ERROR_MISSING_INPUT %windir%\Microsoft.NET\Framework\v4.0.30319\ilasm /nologo /quiet /dll %ILASM_EXTRA_ARGS% /include=%INCLUDE_PATH% /output=%OUTPUT_PATH% %INPUT_PATH% ::: 2.0 or 3.5 :::%windir%\Microsoft.NET\Framework\v2.0.50727\ilasm /nologo /quiet /dll %ILASM_EXTRA_ARGS% /include=%INCLUDE_PATH% /output=%OUTPUT_PATH% %INPUT_PATH% -------------------------------------------------------- On Fri, Mar 22, 2013 at 3:28 PM, Seungweon Park <swpark71@gmail.com> wrote:
Hello,
I downloaded from SVN, and tried to compile it in VS2010 with Windows 2008 R2. However, it requires Mono.Unix reference in error message. so I installed mono(mono-2.10.9-gtksharp-2.12.11-win32-0.exe from http://www.go-mono.com/mono-downloads/download.html. And added Mono.Posix.dll as reference, and compiled again, got error. FYI, I selected build option as DebugWin/x86.
------------------------------------------------------------------------------ The command "call "buildclrmodule.bat" x86 "c:\cvs\pythonnet\src\runtime\" "c:\cvs\pythonnet\src\runtime\bin\x86\release\clr.pyd" copy "c:\cvs\pythonnet\src\runtime\bin\x86\Release\Python.Runtime.dll" "c:\cvs\pythonnet\" copy "c:\cvs\pythonnet\src\runtime\bin\x86\Release\*.pdb" "c:\cvs\pythonnet" copy "c:\cvs\pythonnet\src\runtime\bin\x86\Release\clr.pyd" "c:\cvs\pythonnet" " exited with code 1."
------------------------------------------------------------------------------ Any idea?
Thanks, spark.
[image: Inline image 1]

Your python was built with UCS2 unicode support, rather than UCS4. There is a compiler directive in the VS project of pythonnet for that. Pythons that are compiled UCS2 and UCS4 respectively, are binary incompatible with one another. Hence, pythonnet cannot target both at the same time. -brad On Mar 22, 2013, at 6:42 PM, Seungweon Park <swpark71@gmail.com> wrote:
As I opened the file 'buildclrmodule.bat' it has comment like :: Call with buildclrmodule.bat <AnyCPU|x64> <INPUT_DIRECTORY> <OUTPUT_PATH> I added to support x86 below. and compiled successfully. However, when I run nPython.exe
C:\CVS\Pythonnet>npython
Unhandled Exception: System.EntryPointNotFoundException: Unable to find an entry point named 'PyUnicodeUCS4_FromUnicode' in DLL 'python27'. at Python.Runtime.Runtime.PyUnicode_FromUnicode(String s, Int32 size) at Python.Runtime.Runtime.Initialize() in c:\CVS\Pythonnet\src\runtime\runtime.cs:line 101 at Python.Runtime.PythonEngine.Initialize() in c:\CVS\Pythonnet\src\runtime\pythonengine.cs:line 117 at Python.Runtime.PythonConsole.Main(String[] args) in c:\CVS\Pythonnet\src\console\pythonconsole.cs:line 22
C:\CVS\Pythonnet>
What do I need to run without above message?
Thank you, Spark.
---------------------------------------------------- @echo off
set TARGET_PLATFORM=%1 set INPUT_DIRECTORY=%~2 set INPUT_PATH="%INPUT_DIRECTORY%\clrmodule.il" set OUTPUT_PATH=%3
if %TARGET_PLATFORM%==AnyCPU goto SETUP32 if %TARGET_PLATFORM%==x86 goto SETUP32 if %TARGET_PLATFORM%==x64 goto SETUP64 goto ERROR_BAD_PLATFORM
:SETUP32 set INCLUDE_PATH="%INPUT_DIRECTORY%\x86" goto BUILD_CLR_MODULE
:SETUP64 set INCLUDE_PATH="%INPUT_DIRECTORY%\x64" set ILASM_EXTRA_ARGS=/pe64 /x64 goto BUILD_CLR_MODULE
:ERROR_BAD_PLATFORM echo Unknown target platform: %TARGET_PLATFORM% exit /b 1
:ERROR_MISSING_INPUT echo Can't find input file: %INPUT_PATH% exit /b 1
:BUILD_CLR_MODULE if not exist %INPUT_PATH% goto ERROR_MISSING_INPUT %windir%\Microsoft.NET\Framework\v4.0.30319\ilasm /nologo /quiet /dll %ILASM_EXTRA_ARGS% /include=%INCLUDE_PATH% /output=%OUTPUT_PATH% %INPUT_PATH%
::: 2.0 or 3.5 :::%windir%\Microsoft.NET\Framework\v2.0.50727\ilasm /nologo /quiet /dll %ILASM_EXTRA_ARGS% /include=%INCLUDE_PATH% /output=%OUTPUT_PATH% %INPUT_PATH% --------------------------------------------------------
On Fri, Mar 22, 2013 at 3:28 PM, Seungweon Park <swpark71@gmail.com> wrote: Hello,
I downloaded from SVN, and tried to compile it in VS2010 with Windows 2008 R2. However, it requires Mono.Unix reference in error message. so I installed mono(mono-2.10.9-gtksharp-2.12.11-win32-0.exe from http://www.go-mono.com/mono-downloads/download.html. And added Mono.Posix.dll as reference, and compiled again, got error. FYI, I selected build option as DebugWin/x86.
------------------------------------------------------------------------------ The command "call "buildclrmodule.bat" x86 "c:\cvs\pythonnet\src\runtime\" "c:\cvs\pythonnet\src\runtime\bin\x86\release\clr.pyd" copy "c:\cvs\pythonnet\src\runtime\bin\x86\Release\Python.Runtime.dll" "c:\cvs\pythonnet\" copy "c:\cvs\pythonnet\src\runtime\bin\x86\Release\*.pdb" "c:\cvs\pythonnet" copy "c:\cvs\pythonnet\src\runtime\bin\x86\Release\clr.pyd" "c:\cvs\pythonnet" " exited with code 1." ------------------------------------------------------------------------------ Any idea?
Thanks, spark.
<image.png>
_________________________________________________ Python.NET mailing list - PythonDotNet@python.org http://mail.python.org/mailman/listinfo/pythondotnet
participants (3)
-
Barton
-
brad@fie.us
-
Seungweon Park