QuantConnect / pythonnet

Python for .NET is a package that gives Python programmers nearly seamless integration with the .NET Common Language Runtime (CLR) and provides a powerful application scripting tool for .NET developers.
http://pythonnet.github.io
MIT License
28 stars 27 forks source link

Required explicit path (HintPath) setting for added package #44

Closed Zymlex closed 4 years ago

Zymlex commented 4 years ago

Always required specify the path explicitly to avoid the error: The type 'PyObject' is required here and is unavailable. You must add a reference to assembly 'Python.Runtime, Version=1.0.5.30, Culture=neutral, PublicKeyToken=null'.

<HintPath>$(NUGET_PACKAGES)\quantconnect.pythonnet\1.0.5.30\lib\win\Python.Runtime.dll</HintPath>

fsproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net48</TargetFramework>
    <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
  </PropertyGroup>

  <ItemGroup>
    <Compile Include="Main.fs" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="QuantConnect.Lean" Version="2.4.8585" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="QuantConnect.pythonnet" Version="1.0.5.30" />
    <Reference Include="Python.Runtime, Version=1.0.5.30, Culture=neutral, processorArchitecture=MSIL">
      <HintPath>$(NUGET_PACKAGES)\quantconnect.pythonnet\1.0.5.30\lib\win\Python.Runtime.dll</HintPath>
    </Reference>
  </ItemGroup>

</Project>

Main.fs

namespace Test

open QuantConnect.Data.Market
open QuantConnect.Algorithm

type BasicTemplateAlgorithm() =
    inherit QCAlgorithm()
        override this.Initialize() = ()
        member this.OnData(bar:TradeBars) = ()