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

Skip to content

Setup.py fails with /langversion error #521

Closed
@shahwill

Description

@shahwill

Environment

  • Pythonnet version: 2.3
  • Python version: 3.5.0
  • Operating System: Windows 10

Details

  • I'm trying to install pythonnet on my local machine that has the following packages installed: Python 3.5, pip 9.0.1, setuptools 36.2.7, jsonschema 2.6.0, pytest 3.2.0, and wheel 0.29.0.
  • I've tried installing via Nuget, Pip, and from the source code, all with no luck

Nuget installation attempt

  • I created a C# Console Executable Project in Visual Studio 2017 and added the 2.3.0 version of pythonnet to the project via Nuget.

  • I fixed the badimageformatting error by switching CPU configuration to x86

  • I changed the reference for Python.Runtime.DLL to point to /PythonLocation/Lib/site-packages/Python.Runtime.DLL (which I lifted from /VS17App/packages/pythonnet_py35_dotnet2.3.0/lib/net40/Python.Runtime.DLL after the package was installed)

  • When I run the console executable in VS with a simple line of code using (Py.GIL()) {}, I obtain the following error in VS:

Managed Debugging Assistant 'PInvokeStackImbalance' : 'A call to PInvoke function 'Python.Runtime!Python.Runtime.Runtime::PyImport_ImportModule' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.'

This is the same error referenced in #485 but referencing that runtime DLL does nothing.

Source code installation attempt

I also tried installing from source by cloning the 2.3.0 source into code /PythonLocation/Lib/site-packages/ and running the following command in powershell: python.exe .\setup.py bdist_wheel

This results in the following error stack trace:

running bdist_wheel
running build
running build_ext
Checking for updates from https://www.nuget.org/api/v2/.
Currently running NuGet.exe 4.1.0.
NuGet.exe is up to date.
MSBuild auto-detection: using msbuild version '15.1.1012.6693' from 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\bin'.
All packages listed in packages.config are already installed.
Microsoft (R) Manifest Tool version 6.1.7716.0
Copyright (c) Microsoft Corporation 2009.
All rights reserved.
Microsoft (R) Build Engine version 4.6.1586.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.

Microsoft (R) Build Engine version 4.6.1586.0
[Microsoft .NET Framework, version 4.0.30319.42000]
Copyright (C) Microsoft Corporation. All rights reserved.

CSC : error CS1617: Invalid option '6' for /langversion; must be ISO-1, ISO-2, 3, 4, 5 or Default [C:\Python35\Lib\site-packages\pythonnet\src\runtime\Python.Runtime.csproj]
CSC : error CS1617: Invalid option '6' for /langversion; must be ISO-1, ISO-2, 3, 4, 5 or Default [C:\Python35\Lib\site-packages\pythonnet\src\clrmodule\clrmodule.csproj]
Traceback (most recent call last):
  File ".\setup.py", line 408, in <module>
    zip_safe=False,
  File "C:\Python35\Lib\distutils\core.py", line 148, in setup
    dist.run_commands()
  File "C:\Python35\Lib\distutils\dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "C:\Python35\Lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "C:\Python35\lib\site-packages\wheel\bdist_wheel.py", line 179, in run
    self.run_command('build')
  File "C:\Python35\Lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "C:\Python35\Lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "C:\Python35\Lib\distutils\command\build.py", line 135, in run
    self.run_command(cmd_name)
  File "C:\Python35\Lib\distutils\cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "C:\Python35\Lib\distutils\dist.py", line 974, in run_command
    cmd_obj.run()
  File "C:\Python35\Lib\distutils\command\build_ext.py", line 338, in run
    self.build_extensions()
  File "C:\Python35\Lib\distutils\command\build_ext.py", line 447, in build_extensions
    self._build_extensions_serial()
  File "C:\Python35\Lib\distutils\command\build_ext.py", line 472, in _build_extensions_serial
    self.build_extension(ext)
  File ".\setup.py", line 225, in build_extension
    subprocess.check_call(" ".join(cmd + ["/t:Build"]), shell=use_shell)
  File "C:\Python35\Lib\subprocess.py", line 584, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '"C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe" pythonnet.sln /p:Configuration=ReleaseWin /p:Platform=x86 /p:DefineConstants="PYTHON35%3BPYTHON3%3BUCS2" /p:PythonBuildDir="C:\Python35\Lib\site-packages\pythonnet\build\l
ib.win32-3.5" /p:PythonInteropFile="interop35.cs" /verbosity:minimal /p:PythonManifest="C:\Python35\Lib\site-packages\pythonnet\build\lib.win32-3.5\app.manifest" /t:Build' returned non-zero exit status 1
PS C:\Python35\Lib\site-packages\pythonnet>

Pip installation attempt

I've also tried installing via pip (pip install git+https://github.com/pythonnet/pythonnet -U --force) but that gives the same error as the one mentioned above for the source code.

Summary

I've been stuck on this for days and can't seem to be able to install pythonnet in any way. It seems like it's a C# compiler issue based on my research but I can't seem to figure it out. Any help would be appreciated! Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions