Use of packages

I was trying to use the Base64EncodePipe() function but it didn’t work.
I figured out that I need the type ‘using Base64’ first. This function is from the Standard Library so why is this needed?

And where can I find more information concerning packages and how to use them?


I think this is how Julia works, go to any stdlib,
You will have to import or using them first.

Hi Jerrryling315

Thank you for your answer.

I’ve downgraded my Julia version to 0.7. This is the same version my colleague is using and the necessary packages are installed automatically.

Julia 0.7 differs from 1.0 only in that the old bindings work but give you a deprecation warning.

In 0.7/1.0, a lot of packages got moved out of Base and into their own packages in order to make it easier to push bugfixes and the like to them; they are now in a “stdlib” of preinstalled packages, but like any other regular package you still have to clarify their use with using. You just don’t have to add them first.

1 Like
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation:
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.7.0 (2018-08-08 06:46 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official release
|__/                   |  x86_64-w64-mingw32

julia> Base64EncodePipe()
WARNING: Base.Base64EncodePipe is deprecated: it has been moved to the standard library package `Base64`.
Add `using Base64` to your imports.
 in module Main
ERROR: MethodError: no method matching Base64.Base64EncodePipe()
Closest candidates are:
  Base64.Base64EncodePipe(::IO) at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v0.7\Base64\src\encode.jl:40
 [1] top-level scope at none:0

   _       _ _(_)_     |  Documentation:
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.0.0 (2018-08-08)
 _/ |\__'_|_|_|\__'_|  |  Official release
|__/                   |

julia> using Base64

julia> tmp = tempname()

julia> fil = open(tmp,"w")
IOStream(<file C:\Users\tfr004\AppData\Local\Temp\jl_C5E8.tmp>)

julia> Base64EncodePipe(fil)
Base64EncodePipe(IOStream(<file C:\Users\tfr004\AppData\Local\Temp\jl_C5E8.tmp>), Base64.Buffer(UInt8[0x70, 0x0b, 0x0f, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x70, 0x0b  …  0x00, 0x00, 0x10, 0x0f, 0x57, 0x05, 0x00, 0x00, 0x00, 0x00], Ptr{UInt8} @0x000000000edecef0, 0))

1 Like

This is how most standard libraries work really.

Consider in C, you would need to #include <stdio.h> to have any IO functions, and by default you only have things like +

In python without loading any libraries you only have a few functions and datatyles like dict but if you do from collections import * you also now have defaultdict.

Julia by default you have all the things from the Base standard library – so using Base does nothing.
But for other standard libraries, like Base64 or Test you need to load them using using.

The main thing that makes them standard libraries is that they are distributed with julia.
In general through they are not much different from external packages.
This is intentional; basically nothing in the standard libraries (including Base (but excluding Core)) is in any way privileged over normal user code in another package in capability.


Thank you all for the answers.