Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Troubleshooting FAQ

denfromufa edited this page Sep 2, 2016 · 24 revisions

Welcome to the pythonnet troubleshooting wiki on Windows!

If you get errors first things to check

Latest pythonnet is installed

Pythonnet consists of 2 DLLs: clr.pyd and Python.Runtime.dll, first DLL is used to embed .NET in CPython with import clr statement and second DLL is used to embed CPython in .NET.

From PYPI

pip install pythonnet [--pre] (--pre gets the latest development build uploaded to PyPI)

Built from master branch on github

https://github.com/pythonnet/pythonnet/tree/master

Note that you need to have pip, six, wheel, setuptools installed. Also Windows SDK or Visual Studio (at least free version) need to be installed, since build process locates and uses msbuild.exe and mt.exe.

RGiesecke.DllExport does not support non English ILdasm generated IL file. You can inspect RGiesecke.DllExport with ilspy fixed it. Find and change "// Code" to you system language it in RGiesecke.DllExport.Parsing.Actions.DeleteExportAttributeParserAction.Execute

1. Build in Visual Studio

The correct set of compilation symbols are selected with UCS2 (UCS4 for Mono), x86 or x64 build of CPython and Python version flag (PYTHON27..PYTHON35).

Copy clr.pyd and Python.Runtime.DLL to PYTHONFOLDER\Lib\site-packages\ or include their location path to search paths

2. Build and install from command-line

if GIT is installed: pip install git+https://github.com/pythonnet/pythonnet -U

or from local pythonnet source directory: python.exe setup.py bdist_wheel at runtime or with environment variables.

And install this wheel:

pip install dist/*.whl

Where *.whl is name of wheel in dist directory, that depends on Python version.

Note that pip install wheel is requirement for building wheels.

CPython 2.7-3.5 installed

Installed CPython is reachable by %PATH% or %PYTHONHOME% environment variables.

.NET 4.0+ is installed

Pythonnet relies DLR and Hashset only added since CLR 4.0.

No left-over

No left-over pythonnet assemblies in CPython folders or in GAC for CLR 2/4.

3 WinForms demos

Make sure that all 3 WinForms demos are showing without errors:

  • helloform.py
  • splitter.py
  • wordpad.py

Tests passing

Make sure that all Python tests are passing locally by running this command python pythonnet\src\tests\runtests.py.

Note that Python.Test.dll needs to be copied to PYTHONFOLDER\Lib\site-packages\.

You can also run NUnit tests for embedding CPython in .NET using Python.EmbeddingTest.dll.

Read the tutorial

https://pythonnet.github.io/readme.html

Report back

  • Report wrong result or exception and traceback

  • Report minimal reproducible exception or wrong result

Assembly binding errors

When using .NET DLLs from pythonnet, analyze assembly binding errors using Fuslogvw.exe.

Check history

Check stackoverflow, mailing list archive, and past github issues:

http://stackoverflow.com/questions/tagged/python.net

https://mail.python.org/pipermail/pythondotnet

https://github.com/pythonnet/pythonnet/issues