# Set Julia environment variables from command line call

**URL:** <https://discourse.julialang.org/t/set-julia-environment-variables-from-command-line-call/17234>\
**Category:** General Usage\
**Created:** [November 7, 2018, 1:08am UTC](https://discourse.julialang.org/t/set-julia-environment-variables-from-command-line-call/17234 "2018-11-07T01:08:15Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![kilgoretrout](https://avatars.discourse-cdn.com/v4/letter/k/dc4da7/32.png) [@kilgoretrout](https://discourse.julialang.org/u/kilgoretrout)\
**Post date:** [November 7, 2018, 1:08am UTC](https://discourse.julialang.org/t/set-julia-environment-variables-from-command-line-call/17234/1 "2018-11-07T01:08:15Z")

</div>

Hi,

I am using Julia v0.6. I need to execute the following julia commands for a test:

```julia
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

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [November 7, 2018, 1:19am UTC](https://discourse.julialang.org/t/set-julia-environment-variables-from-command-line-call/17234/2 "2018-11-07T01:19:59Z")

</div>

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…)

---

<div class="post-metadata">

**Author:** ![kilgoretrout](https://avatars.discourse-cdn.com/v4/letter/k/dc4da7/32.png) [@kilgoretrout](https://discourse.julialang.org/u/kilgoretrout)\
**Post date:** [November 7, 2018, 1:24am UTC](https://discourse.julialang.org/t/set-julia-environment-variables-from-command-line-call/17234/3 "2018-11-07T01:24:24Z")

</div>

Oh, I did not realize that `ENV` inside julia is just the usual environment variables. Thanks, this works!

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [November 7, 2018, 1:25am UTC](https://discourse.julialang.org/t/set-julia-environment-variables-from-command-line-call/17234/4 "2018-11-07T01:25:34Z")

</div>

I mean…

```julia
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…)

---

<div class="post-metadata">

**Author:** ![kilgoretrout](https://avatars.discourse-cdn.com/v4/letter/k/dc4da7/32.png) [@kilgoretrout](https://discourse.julialang.org/u/kilgoretrout)\
**Post date:** [November 7, 2018, 1:27am UTC](https://discourse.julialang.org/t/set-julia-environment-variables-from-command-line-call/17234/5 "2018-11-07T01:27:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [November 7, 2018, 1:28am UTC](https://discourse.julialang.org/t/set-julia-environment-variables-from-command-line-call/17234/6 "2018-11-07T01:28:53Z")

</div>

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](https://docs.julialang.org/en/v1/stdlib/REPL/#Help-mode-1) is the first result if you [search for help on the online doc](https://docs.julialang.org/en/v1/search/?q=help).

---

<div class="post-metadata">

**Author:** ![tlienart](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tlienart/32/7640_2.png) [@tlienart](https://discourse.julialang.org/u/tlienart)\
**Post date:** [November 7, 2018, 1:29am UTC](https://discourse.julialang.org/t/set-julia-environment-variables-from-command-line-call/17234/7 "2018-11-07T01:29:36Z")

</div>

just use the question mark in the repl, this will switch to `help?`

so for instance

```julia
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

```

---

<div class="post-metadata">

**Author:** ![kilgoretrout](https://avatars.discourse-cdn.com/v4/letter/k/dc4da7/32.png) [@kilgoretrout](https://discourse.julialang.org/u/kilgoretrout)\
**Post date:** [November 7, 2018, 1:32am UTC](https://discourse.julialang.org/t/set-julia-environment-variables-from-command-line-call/17234/8 "2018-11-07T01:32:27Z")

</div>

Got it, thanks. Googling “julia help in interpreter” didn’t give anything but should have searched the julia docs.

Thanks again

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [November 7, 2018, 1:35am UTC](https://discourse.julialang.org/t/set-julia-environment-variables-from-command-line-call/17234/9 "2018-11-07T01:35:51Z")

</div>

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.
