Hi,
I am using Julia v0.6. I need to execute the following julia commands for a test:
ENV["PYTHON"] = "<path to a specific conda virtual env python>"
using MyPackage # needs to call the above python
But, I am trying to do this in a Dockerfile so would prefer to execute this from the command line using julia -e '<some commands>'
. For example julia -e 'using MyPackage'
is ok.
How can I also tell julia to set its PYTHON
environment variable from the command-line so that it will effect the using MyPackage
call.
I tried setting an extern JULIA_PYTHON
environment variable but that didn’t work.
Thank you
It’s not really julia’s job to set environment variables from the command line. It’s the job of whatever program (shell) that give you the command line. Just set the PYTHON
env from the shell, either as a global setting (no idea about docker) or just put PYTHON=...
before julia
in the same command line. (And in the off-chance that the shell didn’t support that, add env
in front…)
1 Like
Oh, I did not realize that ENV
inside julia is just the usual environment variables. Thanks, this works!
I mean…
help?> ENV
search: ENV withenv DenseVector DenseVecOrMat setenv code_native @code_native
ENV
Reference to the singleton EnvDict, providing a dictionary interface to system environment
variables.
…
(edit: I’m sure you know how to read the doc and forgetting to check from time to time isn’t a big deal… Just want to be clear that this is indeed documented…)
Yeah well I’m very new to julia. I’m not even sure how you got into help?>
…I tried a few things and can’t get there.
You can either use the doc online or just type ?
in the REPL to bring up the help mode.
Note that the help mode doc is the first result if you search for help on the online doc.
just use the question mark in the repl, this will switch to help?
so for instance
julia> 1+1
2
help?> # activated by just entering question mark
help?> isinteger
search: isinteger
isinteger(x) -> Bool
Test whether x is numerically equal to some integer.
Examples
≡≡≡≡≡≡≡≡≡≡
julia> isinteger(4.0)
true
Got it, thanks. Googling “julia help in interpreter” didn’t give anything but should have searched the julia docs.
Thanks again
That’s not the interpreter (the runtime that execute julia code without compiling) but the REPL (the command line interface for julia). Googling “julia help REPL” does shows something useful for me so you might want to try this next time if you need to.