# How to use ANACONDA's Python from Julia

**URL:** <https://discourse.julialang.org/t/how-to-use-anacondas-python-from-julia/4082>\
**Category:** General Usage\
**Created:** [June 4, 2017, 4:24pm UTC](https://discourse.julialang.org/t/how-to-use-anacondas-python-from-julia/4082 "2017-06-04T16:24:40Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![gopal2017](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gopal2017/32/31747_2.png) [@gopal2017](https://discourse.julialang.org/u/gopal2017)\
**Post date:** [June 4, 2017, 4:24pm UTC](https://discourse.julialang.org/t/how-to-use-anacondas-python-from-julia/4082/1 "2017-06-04T16:24:40Z")

</div>

Hi,  
I am using Pycall to call Python from Julia. From Julia Prompt I used Pkg.add(“PyCall”). During its installation its downloading miniconda for Python.  
I have anaconda in my PC and want to use Anaconda’s Python. Is their any way?

---

<div class="post-metadata">

**Author:** ![Ralph\_Smith](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ralph_smith/32/10344_2.png) [@Ralph\_Smith](https://discourse.julialang.org/u/Ralph_Smith)\
**Post date:** [June 4, 2017, 5:54pm UTC](https://discourse.julialang.org/t/how-to-use-anacondas-python-from-julia/4082/2 "2017-06-04T17:54:29Z")

</div>

From [the package README file](https://github.com/JuliaPy/PyCall.jl/blob/master/README.md):

> If you want to use a different version of Python than the default [miniconda], you can change the Python version by setting the PYTHON environment variable to the path of the python executable and then re-running Pkg.build(“PyCall”). In Julia:

> ```julia
> 
> ```

ENV[“PYTHON”] = “… path of the python program you want …”  
Pkg.build(“PyCall”)

```julia

```

---

<div class="post-metadata">

**Author:** ![mzaffalon](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mzaffalon/32/214168_2.png) [@mzaffalon](https://discourse.julialang.org/u/mzaffalon)\
**Post date:** [June 4, 2017, 5:54pm UTC](https://discourse.julialang.org/t/how-to-use-anacondas-python-from-julia/4082/3 "2017-06-04T17:54:46Z")

</div>

~~Is Anaconda’s Python on the path? If so, it should not download a new Python installation.~~

As pointed out by @dpsanders in the post below, this is the default only for Linux. Julia on Windows and Mac downloads a minimal private Python installation.

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [June 4, 2017, 7:07pm UTC](https://discourse.julialang.org/t/how-to-use-anacondas-python-from-julia/4082/4 "2017-06-04T19:07:02Z")

</div>

That changes as of IJulia 1.4 (if I remember correctly). The default is now always to download a new conda installation, to try to ensure the correct versions of everything.

---

<div class="post-metadata">

**Author:** ![Juan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juan/32/7657_2.png) [@Juan](https://discourse.julialang.org/u/Juan)\
**Post date:** [July 17, 2017, 11:49am UTC](https://discourse.julialang.org/t/how-to-use-anacondas-python-from-julia/4082/5 "2017-07-17T11:49:36Z")

</div>

How can you do it on Windows?

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ihnorton/32/26_2.png) [@ihnorton](https://discourse.julialang.org/u/ihnorton)\
**Post date:** [July 17, 2017, 12:56pm UTC](https://discourse.julialang.org/t/how-to-use-anacondas-python-from-julia/4082/6 "2017-07-17T12:56:20Z")

</div>

The same thing should work, or run `set PYTHON=c:\path\to\python` in a prompt before starting julia.

---

<div class="post-metadata">

**Author:** ![bionicinnovations](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bionicinnovations/32/6065_2.png) [@bionicinnovations](https://discourse.julialang.org/u/bionicinnovations)\
**Post date:** [November 14, 2018, 12:35pm UTC](https://discourse.julialang.org/t/how-to-use-anacondas-python-from-julia/4082/7 "2018-11-14T12:35:07Z")

</div>

ive not had any luck with this on windows:

ive tried:

julia\> ENV[“PYTHON”] = “C:\Users\jason\Anaconda3\python.exe”  
ERROR: syntax: invalid escape sequence

and

julia\> ENV[“PYTHON”] = "C:\Users\jason\Anaconda3"  
ERROR: syntax: invalid escape sequence

is it because python.exe is version 3.7.0?

---

<div class="post-metadata">

**Author:** ![Rudi79](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rudi79/32/3884_2.png) [@Rudi79](https://discourse.julialang.org/u/Rudi79)\
**Post date:** [November 14, 2018, 3:20pm UTC](https://discourse.julialang.org/t/how-to-use-anacondas-python-from-julia/4082/8 "2018-11-14T15:20:39Z")

</div>

You can either do it as ihnorton suggested or you can do it the way you tried. When doing the latter, you should escape the backslash. i.e.,  
`ENV["PYTHON"] = "C:\\Users\\jason\\Anaconda3"`  
I am not sure whether you should add `\\python.exe` though.

---

<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:** [November 14, 2018, 3:48pm UTC](https://discourse.julialang.org/t/how-to-use-anacondas-python-from-julia/4082/9 "2018-11-14T15:48:16Z")

</div>

> [@Rudi79](#):
>
> I am not sure whether you should add `\\python.exe` though.

Yes, `PYTHON` should be the path of the Python executable (including the executable name). Note that you can also use `raw"C:\Users\jason\Anaconda3\python.exe"` to avoid escaping the backslashes.
