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

Skip to content

Could not load file or assembly 'Python.Runtime, Version=2.4.0.0... #665

Closed
@tomunger

Description

@tomunger

Environment

  • Pythonnet version: 2.4.00
  • Python version: 2.7.13
  • Operating System: Windows 7

Details

  • Describe what you were trying to get done.

I have used pip install git+https://github.com/pythonnet/pythonnet
to install latest python net.

I've created a .NET visual studio 2015 project to make calls to Python. I reference the Python.Runtime.dll file in the project. When I let it get copied to the binary directory of my project calls to CPython work fine.

Now, I don't want to bundle the DLL with my application. As I understand, different versions work with different versions of CPython. I would like to load Python.Runtime.dll from Lib\site-packages so I get version appropriate for version of Python installed on the system. I change properties of the PythonRuntime.dll reference to NOT copy the DLL to bin directory. Now I get the error:

An unhandled exception of type 'System.IO.FileNotFoundException' occurred in PyRunner.exe
Additional information: Could not load file or assembly 'Python.Runtime, Version=2.4.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

This minimal program causes the error.

using Python.Runtime;

namespace PyRunner
{
	class ErrorExample
	{
		static void Main(string[] args)
		{
			PythonEngine.Initialize();
		}
	}
}

I've tracked down other issues related to this but none seem to simply be that the DLL is not found.

When I try to install the assembly in the GAC I get

>gacutil /i Lib\site-packages\Python.Runtime.dll
Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Failure adding assembly to the cache: Attempt to install an assembly without a strong name

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