# Set ENV\["PYTHON"\]="pythoncommand"

**URL:** <https://discourse.julialang.org/t/set-env-python-pythoncommand/28439>\
**Category:** New to Julia\
**Created:** [September 5, 2019, 6:39pm UTC](https://discourse.julialang.org/t/set-env-python-pythoncommand/28439 "2019-09-05T18:39:34Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![hasanOryx](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hasanoryx/32/5373_2.png) [@hasanOryx](https://discourse.julialang.org/u/hasanOryx)\
**Post date:** [September 5, 2019, 6:39pm UTC](https://discourse.julialang.org/t/set-env-python-pythoncommand/28439/1 "2019-09-05T18:39:34Z")

</div>

I just installed `Python3` from the installer at my `Windows 10` device, and got this error while trying `Pkg.add("PyPlot")`

In my `Mac` I also installed `python3` from the installer, and got the same error

```bash
┌ Error: Error building `PyCall`: 
│ ┌ Info: Using the Python distribution in the Conda package by default.
│ └ To use a different Python version, set ENV["PYTHON"]="pythoncommand" and re-run Pkg.build("PyCall").

```

In the terminal I tried:

```bash
set ENV["PYTHON"]="python3"

```

But did not work, it looks I did not understood the note.

I read some topics of the recommendations appeared while writing this, but did not get exact issue!

---

<div class="post-metadata">

**Author:** ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Post date:** [September 5, 2019, 6:50pm UTC](https://discourse.julialang.org/t/set-env-python-pythoncommand/28439/2 "2019-09-05T18:50:06Z")

</div>

Did you set `ENV["PYTHON"]` in the Julia session _before_ you ran `]build PyCall`?

Can you also do `which python3` and ensure it returns and non-empty string from a fresh terminal session?

---

<div class="post-metadata">

**Author:** ![hasanOryx](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hasanoryx/32/5373_2.png) [@hasanOryx](https://discourse.julialang.org/u/hasanOryx)\
**Post date:** [September 5, 2019, 6:55pm UTC](https://discourse.julialang.org/t/set-env-python-pythoncommand/28439/3 "2019-09-05T18:55:57Z")

</div>

> [@ExpandingMan](#):
>
> ENV[“PYTHON”]

I think this what I did not understood, put what and where, what shall I write and where?

---

<div class="post-metadata">

**Author:** ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Post date:** [September 5, 2019, 6:58pm UTC](https://discourse.julialang.org/t/set-env-python-pythoncommand/28439/4 "2019-09-05T18:58:13Z")

</div>

Oh, sorry I just realized that you said you did that in the terminal.

In Julia, `ENV` is a global dictionary that stores the current environment. Take a look at it by typing `ENV` in the REPL. What the PyCall install is asking you to do is to set `ENV["PYTHON"] = "/path/to/python/binary"` in Julia before you call `]build PyCall`.

---

<div class="post-metadata">

**Author:** ![hasanOryx](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hasanoryx/32/5373_2.png) [@hasanOryx](https://discourse.julialang.org/u/hasanOryx)\
**Post date:** [September 5, 2019, 7:19pm UTC](https://discourse.julialang.org/t/set-env-python-pythoncommand/28439/5 "2019-09-05T19:19:29Z")

</div>

Thanks, I got the path in Mac using below at `terminal`:

```bash
 $ which python3

```

Then in `Julia REPL` I wrote:

```bash
ENV["PYTHON"]="/Library/Frameworks/Python.framework/Versions/3.7/bin/python3"

```

Then run in the REPLT

```bash
Pkg.build("PyCall")

```

Then I got this error:

```bash
ERROR: LoadError: InitError: PyCall.PyError("PyImport_ImportModule\n\nThe Python package matplotlib could not be found by pyimport. Usually this means\nthat you did not install matplotlib in the Python version being used by PyCall.\n\nPyCall is currently configured to use the Python version at:\n\n/Library/Frameworks/Python.framework/Versions/3.7/bin/python3\n\nand you should use whatever mechanism you usually use (apt-get, pip, conda,\netcetera) to install the Python package containing the matplotlib module

```

So, I install `matplot` in the `terminal`as:

```bash
$ pip3 install matplotlib

```

Then I forced to do recompiling for `Pkg.add("PyPlot")`, to get it done.

Now below code works fine at `jupyter lab`

```julia
Pkg.add("Plots")
Pkg.add("Measures")
Pkg.add("PyPlot")
println("hello from Julia function")
using Plots, Measures
pyplot()

data = [rand(100), rand(100)];

h = histogram(data, layout = 2,
              title = ["Dataset A" "Dataset B"], legend = false,
              ylabel = "ylabel", margin = 5mm)
display(h)

```

In `Windows 10` the path was

```bash
ENV["PYTHON"]="C:/Program Files (x86)/Python37-32/python"

```

But while executing `Pkg.build("PyCall")` I got an error:

```bash
┌ Error: Error building `PyCall`: 
│ ┌ Info: No system-wide Python was found; got the following error:
│ │ ErrorException("C:/Program Files (x86)/Python37-32/python is 32-bit, but Julia is 64-bit")
│ └ using the Python distribution in the Conda package

```

So, I got forced to remove the 32bit edition of Python3, and install the 64bit edition and fixed the ENV in the ``REPL` as:

```bash
ENV["PYTHON"]="C:/Program Files/Python37/python"

```

And faced in Windows this error:

```bash
LoadError: FFMPEG not installed properly

```

So I downloaded the build from [here](https://ffmpeg.zeranoe.com/builds/), unzipped it, and added it to the path.

Thanks

---

<div class="post-metadata">

**Author:** ![jmaffi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmaffi/32/9784_2.png) [@jmaffi](https://discourse.julialang.org/u/jmaffi)\
**Post date:** [November 6, 2021, 12:50pm UTC](https://discourse.julialang.org/t/set-env-python-pythoncommand/28439/6 "2021-11-06T12:50:18Z")

</div>

Hello everyone,

I’ve been having a similar issue; found several threads on the matter but still haven’t been able to figure it out.

This is the error message I get:

```julia
    Building PyCall → `C:\Users\Lali\.julia\scratchspaces\44cfe95a-1eb2-52ea-b672-e2afdf69b78f\4ba3651d33ef76e24fef6a598b63ffd1c5e1cd17\build.log`
ERROR: Error building `PyCall`:
┌ Info: Using the Python distribution in the Conda package by default.
└ To use a different Python version, set ENV["PYTHON"]="pythoncommand" and re-run Pkg.build("PyCall").
[ Info: Running `conda install -y numpy` in root environment
ERROR: LoadError: failed process: Process(setenv(`'C:\Users\Lali\.julia\conda\3\Scripts\conda.exe' install -y numpy`,["PATH=C:\\Users\\Lali\\.julia\\conda\\3\\Library\\bin;C:\\Program Files (x86)\\Common Files\\Oracle\\Java\\javapath;C:\\Program Files (x86)\\Intel\\iCLS Client\\;C:\\Program Files\\Intel\\iCLS Client\\;C:\\Windows\\system32;C:\\Windows;C:\\Windows\\System32\\Wbem;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\DAL;C:\\Program Files\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files (x86)\\Intel\\Intel(R) Management Engine Components\\IPT;C:\\Program Files\\MATLAB\\runtime\\win64;C:\\Program Files\\MATLAB\\bin;C:\\Program Files\\Polyspace\\R2021a\\runtime\\win64;C:\\Program Files\\Polyspace\\R2021a\\bin;C:\\Program Files\\MATLAB\\R2019a\\runtime\\win64;C:\\Program Files\\MATLAB\\R2019a\\bin;C:\\Program Files\\MATLAB\\R2018a\\runtime\\win64;C:\\Program Files\\MATLAB\\R2018a\\bin;C:\\Program Files (x86)\\MATLAB\\MATLAB Compiler Runtime\\v713\\runtime\\win32;C:\\Program Files\\Common Files\\Autodesk Shared\\;C:\\Program Files\\MATLAB\\polyspace\\bin;C:\\Program Files\\MATLAB\\MATLAB Runtime\\v901\\runtime\\win64;C:\\Program Files\\MiKTeX 2.9\\miktex\\bin\\x64\\;C:\\Program Files (x86)\\Wolfram Research\\WolframScript\\;C:\\Program Files\\MATLAB\\R2019a\\polyspace\\bin;C:\\Julia-1.5.0\\bin;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\;C:\\Julia-1.5.0\\bin;C:\\Program Files\\NVIDIA Corporation\\NVIDIA NvDLISR;C:\\Program Files (x86)\\NVIDIA Corporation\\PhysX\\Common;C:\\Program Files\\Polyspace\\R2021a\\polyspace\\bin;C:\\Users\\Lali\\AppData\\Local\\atom\\bin;C:\\Julia-1.6.3\\bin", "HOMEPATH=\\Users\\Lali", "PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC", "NODE_ENV=production", "SESSIONNAME=Console", "SYSTEMROOT=C:\\Windows", "APPDATA=C:\\Users\\Lali\\AppData\\Roaming", "PSMODULEPATH=C:\\Windows\\system32\\WindowsPowerShell\\v1.0\\Modules\\", "COMMONPROGRAMW6432=C:\\Program Files\\Common Files", "PROGRAMDATA=C:\\ProgramData" … "CHROME_CRASHPAD_PIPE_NAME=\\\\.\\pipe\\crashpad_7488_APRVFBOJAOFUAMQU", "LOGONSERVER=\\\\POLYMOD", "ORIGINAL_XDG_CURRENT_DESKTOP=undefined", "ILMDIR=C:\\Program Files (x86)\\Common Files\\Autodesk Shared\\Materials\\", "CONDA_PREFIX=C:\\Users\\Lali\\.julia\\conda\\3", "ATOM_HOME=C:\\Users\\Lali\\.atom", "JULIA_LOAD_PATH=@;C:\\Users\\Lali\\AppData\\Local\\Temp\\jl_GsxjSn", "SYSTEMDRIVE=C:", "PROCESSOR_ARCHITECTURE=AMD64", "OPENBLAS_MAIN_FREE=1"]), ProcessExited(3221225595)) [3221225595]

Stacktrace:
 [1] pipeline_error
   @ .\process.jl:525 [inlined]
 [2] run(::Cmd; wait::Bool)
   @ Base .\process.jl:440
 [3] run
   @ .\process.jl:438 [inlined]
 [4] runconda(args::Cmd, env::String)
   @ Conda C:\Users\Lali\.julia\packages\Conda\sNGum\src\Conda.jl:129
 [5] add(pkg::String, env::String; channel::String)
   @ Conda C:\Users\Lali\.julia\packages\Conda\sNGum\src\Conda.jl:221
 [6] add (repeats 2 times)
   @ C:\Users\Lali\.julia\packages\Conda\sNGum\src\Conda.jl:220 [inlined]
 [7] top-level scope
   @ C:\Users\Lali\.julia\packages\PyCall\3fwVL\deps\build.jl:79
 [8] include(fname::String)
   @ Base.MainInclude .\client.jl:444
 [9] top-level scope
   @ none:5
in expression starting at C:\Users\Lali\.julia\packages\PyCall\3fwVL\deps\build.jl:43
Stacktrace:
  [1] pkgerror(msg::String)
    @ Pkg.Types C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Types.jl:55
  [2] (::Pkg.Operations.var"#82#87"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec})()
    @ Pkg.Operations C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Operations.jl:1048
  [3] withenv(::Pkg.Operations.var"#82#87"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, ::Pair{String, String}, ::Vararg{Pair{String, B} where B, N} where N)
    @ Base .\env.jl:161
  [4] (::Pkg.Operations.var"#109#113"{String, Pkg.Operations.var"#82#87"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, Pkg.Types.PackageSpec})()
    @ Pkg.Operations C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Operations.jl:1546
  [5] with_temp_env(fn::Pkg.Operations.var"#109#113"{String, Pkg.Operations.var"#82#87"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, Pkg.Types.PackageSpec}, temp_env::String)
    @ Pkg.Operations C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Operations.jl:1448
  [6] (::Pkg.Operations.var"#108#112"{Pkg.Operations.var"#82#87"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, Pkg.Types.Context, Pkg.Types.PackageSpec, String, Pkg.Types.Project, String})(tmp::String)
    @ Pkg.Operations C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Operations.jl:1521
  [7] mktempdir(fn::Pkg.Operations.var"#108#112"{Pkg.Operations.var"#82#87"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, Pkg.Types.Context, Pkg.Types.PackageSpec, String, Pkg.Types.Project, String}, parent::String; prefix::String)
    @ Base.Filesystem .\file.jl:729
  [8] mktempdir(fn::Function, parent::String) (repeats 2 times)
    @ Base.Filesystem .\file.jl:727
  [9] sandbox(fn::Function, ctx::Pkg.Types.Context, target::Pkg.Types.PackageSpec, target_path::String, sandbox_path::String, sandbox_project_override::Pkg.Types.Project)
    @ Pkg.Operations C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Operations.jl:1487
 [10] build_versions(ctx::Pkg.Types.Context, uuids::Vector{Base.UUID}; verbose::Bool)
    @ Pkg.Operations C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Operations.jl:1029
 [11] build(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}, verbose::Bool)
    @ Pkg.Operations C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\Operations.jl:910
 [12] build(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; verbose::Bool, kwargs::Base.Iterators.Pairs{Symbol, Base.TTY, Tuple{Symbol}, NamedTuple{(:io,), Tuple{Base.TTY}}})
    @ Pkg.API C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:900
 [13] build(pkgs::Vector{Pkg.Types.PackageSpec}; io::Base.TTY, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Pkg.API C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:80
 [14] build(pkgs::Vector{Pkg.Types.PackageSpec})
    @ Pkg.API C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:78
 [15] #build#71
    @ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:76 [inlined]
 [16] build
    @ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:76 [inlined]
 [17] #build#70
    @ C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:75 [inlined]
 [18] build(pkg::String)
    @ Pkg.API C:\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.6\Pkg\src\API.jl:75
 [19] top-level scope
    @ none:1

```

Any ideas? I’m using Julia v 1.6.3 (2021-09-23) on Atom.

Thanks a lot!

---

<div class="post-metadata">

**Author:** ![ctkelley](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ctkelley/32/10684_2.png) [@ctkelley](https://discourse.julialang.org/u/ctkelley)\
**Post date:** [January 7, 2022, 9:22pm UTC](https://discourse.julialang.org/t/set-env-python-pythoncommand/28439/7 "2022-01-07T21:22:36Z")

</div>

Try

```julia
ENV["PYTHON"]=""

```

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [January 7, 2022, 9:56pm UTC](https://discourse.julialang.org/t/set-env-python-pythoncommand/28439/8 "2022-01-07T21:56:12Z")

</div>

> [@jmaffi](#):
>
> `C:\Users\Lali\.julia\conda\3\Scripts\conda.exe`

What happens if you try running `C:\Users\Lali\.julia\conda\3\Scripts\conda.exe` from your OS terminal?

(If your Conda installation is corrupted somehow, you could delete the `C:\Users\Lali\.julia\conda` directory and try again.)
