Reputation: 96586
Suppose in the Julia console I do
using Gadfly
And then realise I actually want to use a different plot command
using Winston
It seems that plot()
will still use the Gadfly version. Is there any way to stop using Gadfly?
using !Gadfly
!using Gadfly
unuse Gadfly
Something like that?
Upvotes: 17
Views: 7269
Reputation: 1760
I met the same problem when comparing different plotting frameworks.
The final solution is to use import
instead of using
.
You have to write a little more code than before:
Gadfly.plot(...)
Winston.plot(...)
vs
plot(...)
However, there's no need to restart REPL. For JIT language like Julia, restarting wastes too much compilation time.
Upvotes: 0
Reputation: 1145
As mentioned in the link by @Jubobs, there is currently not a way to selectively stop using a package, or selectively remove a definition from the REPL (similar to Matlab's clear
command if you are familiar with it). So the short answer is no.
However, you can reference functions from specific modules by using Gadfly.plot()
, or Winston.plot()
. This doesn't provide you a solution to your problem if you have already written the code, but it is still an option for future work.
There is the workspace()
command but that will remove everything from the Main
module and will import a fresh Julia environment. You will lose all the functions and variables you have defined... so use it wisely
As @Matt B pointed out, you don't actually lose your functions and variables. They are moved to a module called LastMain
. So if I have a function defined called myfunc()
, and I call workspace()
, then attempting to call myfunc()
at the REPL will result in an UndefVarError
. However, you will still be able access this function by calling LastMain.myfunc()
. This is true of anything that was defined in the REPL before your call to workspace()
.
Upvotes: 13
Reputation: 5063
As others have pointed out, you cannot unload a package in Julia. The only way to do that would be to restart the Julia repl. However, if you want to use a specific function from a package, you can us Winston.plot()
or Gadfly.plot()
. Thus will ensure, you're using the right function from the desired namespace.
Upvotes: 7