#以F#交互式(FSharpChart.fsx)加载程序包 [英] #load a package in F# interactive (FSharpChart.fsx)
问题描述
我是菜鸟,问这个新手问题,请原谅我.
我已经在本地目录中成功安装了FSharpChart
...
Added package 'MSDN.FSharpChart.dll.0.60.0' to folder 'C:\Users\Fagui\Documents\GitHub\Learning Fsharp\Expert in F\packages'
Added package 'MSDN.FSharpChart.dll.0.60.0' to 'packages.config'
Successfully installed 'MSDN.FSharpChart.dll 0.60.0' to Expert in F
现在,如果我愿意
#load "FSharpChart.fsx";;
^^^^^^^^^^^^^^^^^^^^^^^
stdin(4,1): error FS0078: Unable to find the file 'FSharpChart.fsx' in any of
C:\Users\Fagui\AppData\Local\Temp
其他信息:
在此文件夹中,我看到一个nupkg文件和一个lib目录 在lib目录中,有一个dll和一个pdf文件, 但我看不到任何.fsx文件.
基本上,F#已将软件包安装在当前项目的活动文件夹中,而F#interactive在另一个文件夹中?有点奇怪?
我应该再次安装该软件包吗?或解决的方法是什么?
谢谢
更新: 我不知道为什么,但是显然当我安装FSharpChart软件包时,我只得到了dll,没有fsx文件 我设法将其加载
#I @"C:\Users\Fagui\Documents\GitHub\Learning Fsharp\Expert in F"
#r @"packages\MSDN.FSharpChart.dll.0.60\lib\MSDN.FSharpChart.dll";;
不幸的是,在F#交互式环境中键入脚本
open MSDN.FSharp.Charting
let rnd = System.Random()
let rand() = rnd.NextDouble()
let randomPoints = [for i in 0 .. 1000 -> 10.0 * rand(), 10.0 * rand()]
randomPoints |> FSharpChart.Point;;
不产生任何图表,只返回一个列表
val rnd : Random
val rand : unit -> float
val randomPoints : (float * float) list =
[(9.765916457, 2.272289941); (0.8211438594, 1.625466995);
...
(7.783786034, 7.572208311); (6.497914692, 3.66987128); ...]
val it : ChartTypes.PointChart
这可能是由于该库不再受支持,我应该使用像Thomas Petricek所示的较新的库.
所以,我确实设法安装了FSharp.Charting
let rnd = System.Random()
let rand() = rnd.NextDouble()
let randomPoints = [for i in 0 .. 1000 -> 10.0 * rand(), 10.0 * rand()]
randomPoints |> Chart.Point;;
它确实起作用
有FSharpChart.fsx
库的较新版本,称为有关该库的详细页面. /p>
通常,当您使用NuGet引用库时,需要指定相对引用:
// On Mac OSX use packages/FSharp.Charting.Gtk.0.90.13/FSharp.Charting.Gtk.fsx
#load "packages/FSharp.Charting.0.90.13/FSharp.Charting.fsx"
0.90.13
是从NuGet获得的库的版本(您可能需要检查文件夹名称-#load
中的路径引用是相对于脚本所在的位置的.)
Hi i'm a noob and asking this newbie question, please forgive me.
I've installed successfully FSharpChart in my local directory
...
Added package 'MSDN.FSharpChart.dll.0.60.0' to folder 'C:\Users\Fagui\Documents\GitHub\Learning Fsharp\Expert in F\packages'
Added package 'MSDN.FSharpChart.dll.0.60.0' to 'packages.config'
Successfully installed 'MSDN.FSharpChart.dll 0.60.0' to Expert in F
now, if i do
#load "FSharpChart.fsx";;
^^^^^^^^^^^^^^^^^^^^^^^
stdin(4,1): error FS0078: Unable to find the file 'FSharpChart.fsx' in any of
C:\Users\Fagui\AppData\Local\Temp
additional info:
inside this folder, i see a nupkg file, and a lib directory Inside the lib directory, there is a dll, and a pdf file, but i don't see any .fsx file.
basically, F# has installed the package in the active folder for the current project, and F#interactive is in another folder ?? bit strange ?
should i install another time the package ? or what is the way around it ?
thanks
UPDATE: i don't know why, but apparently when i installed the FSharpChart package, I only got the dll, no fsx file i managed to load it doing
#I @"C:\Users\Fagui\Documents\GitHub\Learning Fsharp\Expert in F"
#r @"packages\MSDN.FSharpChart.dll.0.60\lib\MSDN.FSharpChart.dll";;
unfortunately, typing the script in F# interactive
open MSDN.FSharp.Charting
let rnd = System.Random()
let rand() = rnd.NextDouble()
let randomPoints = [for i in 0 .. 1000 -> 10.0 * rand(), 10.0 * rand()]
randomPoints |> FSharpChart.Point;;
doesn't yield any chart, but just returns a list
val rnd : Random
val rand : unit -> float
val randomPoints : (float * float) list =
[(9.765916457, 2.272289941); (0.8211438594, 1.625466995);
...
(7.783786034, 7.572208311); (6.497914692, 3.66987128); ...]
val it : ChartTypes.PointChart
this may be due to the fact that the library is not supported anymore, and that i should use a newer library like Thomas Petricek indicated.
So, i did manage to install FSharp.Charting instead
let rnd = System.Random()
let rand() = rnd.NextDouble()
let randomPoints = [for i in 0 .. 1000 -> 10.0 * rand(), 10.0 * rand()]
randomPoints |> Chart.Point;;
and it did work
There is a newer version of the FSharpChart.fsx
library which is called F# Charting, so first of all, I would recommend using this newer library instead (the API is quite similar, but F# Charting has a number of improvements).
The documentation for F# Charting also has a detailed page on referencing the library.
Typically, when you reference the library using NuGet, you'll need to specify relative reference:
// On Mac OSX use packages/FSharp.Charting.Gtk.0.90.13/FSharp.Charting.Gtk.fsx
#load "packages/FSharp.Charting.0.90.13/FSharp.Charting.fsx"
Where 0.90.13
is the version of the library that you got from NuGet (you may need to check the folder name - the path references in #load
are relative to the place where your script lives).
这篇关于#以F#交互式(FSharpChart.fsx)加载程序包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!