为什么我会得到F#error FS0039:名称空间或模块';Http';没有定义

为什么我会得到F#error FS0039:名称空间或模块';Http';没有定义,f#,f#-interactive,f#-data,F#,F# Interactive,F# Data,在Visual Studio 2015和2017中,我正在试用FSharp Interactive中几个F#示例中的Http类,我不断得到: 错误FS0039:未定义命名空间或模块“Http” 以下是示例: open FSharp.Data let response = Http.RequestString("http://api.themoviedb.org/3/search/movie", silentHttpErrors = true) 这显然是由于FSharp.Data的版本。有没有办

在Visual Studio 2015和2017中,我正在试用FSharp Interactive中几个F#示例中的Http类,我不断得到:

错误FS0039:未定义命名空间或模块“Http”

以下是示例:

open FSharp.Data
let response = Http.RequestString("http://api.themoviedb.org/3/search/movie", silentHttpErrors = true)

这显然是由于FSharp.Data的版本。有没有办法为FSharp Interactive指定正确的版本?哪个版本的FSharp.Data包含Http模块?

根据这些评论,我编写了一个脚本来安装Paket,初始化它,然后在脚本运行时可以选择安装依赖项

/// install.paket.fsx
open System
open System.IO

printfn "Initialising..."
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
// invisibly run a command (paket.exe in this case)
let init paket =
    let psi = new System.Diagnostics.ProcessStartInfo(paket)
    psi.Arguments <- "init"
    psi.UseShellExecute <- false
    let p = System.Diagnostics.Process.Start(psi)
    p.WaitForExit()
    p.ExitCode

if not (File.Exists "paket.exe") then
    printfn "installing paket"
    let url = "http://fsprojects.github.io/Paket/stable"
    use wc = new Net.WebClient()
    let tmp = Path.GetTempFileName()
    let stable = wc.DownloadString(url)
    wc.DownloadFile(stable, tmp)
    File.Move(tmp,Path.GetFileName stable)
    printfn "paket installed"
    System.Threading.Thread.Sleep(100)
    printfn "initialising paket"
    init "paket.exe" |> ignore
    System.Threading.Thread.Sleep(200)
    printfn "paket initialised"
else
    printfn "paket already exists"

/// install.dependencies.fsx

open System.IO
printfn "Installing dependencies"
System.Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
#r "paket.exe"

open Paket
let dependencies = Paket.Dependencies.Locate(__SOURCE_DIRECTORY__)

printfn "%s" dependencies.DependenciesFile

if not (File.Exists "packages/Newtonsoft.Json/lib/net40/Newtonsoft.Json.dll") then
    printfn "installing nuget depenencies"
    // either use the dependencies.Install to add dependencies in the paket.dependencies file
    //dependencies.Install true |> ignore
    // or install them by name
    // I remove the existing versions
    dependencies.Remove "FSharp.Data"
    dependencies.Remove "Newtonsoft.Json 8.0.3"
    // then add them (because I'm pedantic about the way the dependencies file looks)
    dependencies.Add "FSharp.Data"
    dependencies.Add "Newtonsoft.Json 8.0.3"
    printfn "nuget depenencies installed"
else
    printfn "nuget depenencies already exist"

printfn "Dependencies installed"
///install.paket.fsx
开放系统
开放系统
printfn“初始化…”

Environment.CurrentDirectory是否引用了该库?我使用的
open FSharp.Data
是否引用了过期版本?如何从FSharp交互中引用最新的FSharp.Data.dll您需要通过nuget或paket安装FSharp.Data。它将进入项目/解决方案文件夹中的packages子文件夹中。然后在fsproj文件中引用(对于fs文件),或者通过fsx文件中的
#r path/to/Fsharp/Data/Dll
引用。然后你可以打开它。可能您错过了其中一个步骤。由于使用了旧的(v3)类型提供程序,因此有一个全局FSharp.Data命名空间。你可能只是在打开它。但你实际上需要得到这个包裹。在F#聊天时打电话给我,必要时放松一下。
System.Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
#load "install.paket.fsx"
#load "install.dependencies.fsx"

#r "packages/fsharp.data/lib/net40/fsharp.data.dll"
#r "packages/Newtonsoft.Json/lib/net40/Newtonsoft.Json.dll"

open FSharp.Data
open FSharp.Data.HtmlAttribute
open FSharp.Data.HtmlNode
open FSharp.Data.HttpRequestHeaders
open Newtonsoft.Json
open System.Net
open System.IO
// utilities like authentication, Http requests and JSON (de)serialization
System.Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
#load "utilities.fsx"
open Utilities