# Problems configuring PyCall

**URL:** <https://discourse.julialang.org/t/problems-configuring-pycall/11786>\
**Category:** New to Julia\
**Tags:** pyplot\
**Created:** [June 19, 2018, 3:59pm UTC](https://discourse.julialang.org/t/problems-configuring-pycall/11786 "2018-06-19T15:59:23Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![sbacelar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sbacelar/32/4359_2.png) [@sbacelar](https://discourse.julialang.org/u/sbacelar)\
**Post date:** [June 19, 2018, 3:59pm UTC](https://discourse.julialang.org/t/problems-configuring-pycall/11786/1 "2018-06-19T15:59:23Z")

</div>

I am using macOS 12.13.5. I have problems using `PyPlot` in Jupyter using Julia and with Juno in Julia Pro. I created two environment variables in my `.bash_profile` (PYTHON and JUPYTER) pointing to my Anaconda path (`/Users/my_name/anaconda3/bin/python`) for python 3. I did the same for Jupyter.  
After that, I launched `JuliaPro-0.6.2.2` from Terminal and tried to rebuild PyCall package using `Pkg.build("PyCall")` but I got the following problem (PyCall is not using my Python PATH):

```julia
INFO: Building Conda
INFO: Building PyCall
INFO: PyCall is using /usr/bin/python (Python 2.7.10) at /usr/bin/python, libpython = /System/Library/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7

```

---

<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:** [June 19, 2018, 4:24pm UTC](https://discourse.julialang.org/t/problems-configuring-pycall/11786/2 "2018-06-19T16:24:48Z")

</div>

Try explicitly setting `ENV["PYTHON"]` to the path you’d like it to use.

---

<div class="post-metadata">

**Author:** ![sbacelar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sbacelar/32/4359_2.png) [@sbacelar](https://discourse.julialang.org/u/sbacelar)\
**Post date:** [June 19, 2018, 4:58pm UTC](https://discourse.julialang.org/t/problems-configuring-pycall/11786/3 "2018-06-19T16:58:51Z")

</div>

Thanks. I did it an hour ago and it works both in Jupyter and in Juno.  
I don’t understand why simply defining the `PYTHON` variable in `.bash_profile` was not enough.

---

<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:** [June 19, 2018, 5:31pm UTC](https://discourse.julialang.org/t/problems-configuring-pycall/11786/4 "2018-06-19T17:31:13Z")

</div>

> [@sbacelar](#):
>
> I don’t understand why simply defining the `PYTHON` variable in `.bash_profile` was not enough.

Neither do I, it’s supposed to load that in the environment. Stupid question, but did you explicitly check `echo $PYTHON` right before you launched Julia to check that it was set correctly?

---

<div class="post-metadata">

**Author:** ![sbacelar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sbacelar/32/4359_2.png) [@sbacelar](https://discourse.julialang.org/u/sbacelar)\
**Post date:** [June 19, 2018, 5:44pm UTC](https://discourse.julialang.org/t/problems-configuring-pycall/11786/5 "2018-06-19T17:44:57Z")

</div>

Yes, I did it, both for `PYTHON` and `JUPYTER`.

---

<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:** [June 19, 2018, 5:52pm UTC](https://discourse.julialang.org/t/problems-configuring-pycall/11786/6 "2018-06-19T17:52:33Z")

</div>

I suspect that somehow Jupyter is running in a different environment, but I don’t use it, so I don’t know for sure.

---

<div class="post-metadata">

**Author:** ![sbacelar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sbacelar/32/4359_2.png) [@sbacelar](https://discourse.julialang.org/u/sbacelar)\
**Post date:** [June 19, 2018, 6:05pm UTC](https://discourse.julialang.org/t/problems-configuring-pycall/11786/7 "2018-06-19T18:05:39Z")

</div>

I had problems before with `PyPlot` and `Jupyter`. Now they are solved.  
I followed the instructions in the `Julia Pro` manual.

---

<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:** [June 19, 2018, 8:13pm UTC](https://discourse.julialang.org/t/problems-configuring-pycall/11786/8 "2018-06-19T20:13:31Z")

</div>

Note that you only need to set these environment vars the first time you run `Pkg.build`, and the PyCall and IJulia packages will subsequently remember the setting, so there is no need to set them permanently in your `.bash_profile`.

---

<div class="post-metadata">

**Author:** ![sbacelar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sbacelar/32/4359_2.png) [@sbacelar](https://discourse.julialang.org/u/sbacelar)\
**Post date:** [June 20, 2018, 1:00am UTC](https://discourse.julialang.org/t/problems-configuring-pycall/11786/9 "2018-06-20T01:00:02Z")

</div>

OK. Thank you for your advice.

No dia 19/06/2018, às 21:18, Steven G. Johnson [julialang@discoursemail.com](mailto:julialang@discoursemail.com) escreveu:

---

<div class="post-metadata">

**Author:** ![jmert](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jmert/32/3161_2.png) [@jmert](https://discourse.julialang.org/u/jmert)\
**Post date:** [June 20, 2018, 1:23am UTC](https://discourse.julialang.org/t/problems-configuring-pycall/11786/10 "2018-06-20T01:23:24Z")

</div>

> [@ExpandingMan](#):
>
> > [@sbacelar](#):
> >
> > I don’t understand why simply defining the `PYTHON` variable in `.bash_profile` was not enough.
> 
> Neither do I, it’s supposed to load that in the environment. Stupid question, but did you explicitly check `echo $PYTHON` right before you launched Julia to check that it was set correctly?

Did you `export` the variable? i.e. the difference between:

```bash
PYTHON=/path/to/python

```

and

```julia
export PYTHON=/path/to/python

```

Non-exported variables aren’t inherited by child processes, so while you can `echo` in a shell (which will source your `.bash_profile`), things you start after that won’t see the variable. An example of this is:

```bash
$ TESTVAR=nonempty
$ echo $TESTVAR
nonempty
$ bash -c 'echo $TESTVAR'

$ export TESTVAR
$ bash -c 'echo $TESTVAR'
nonempty

```

---

<div class="post-metadata">

**Author:** ![sbacelar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sbacelar/32/4359_2.png) [@sbacelar](https://discourse.julialang.org/u/sbacelar)\
**Post date:** [June 20, 2018, 7:39am UTC](https://discourse.julialang.org/t/problems-configuring-pycall/11786/11 "2018-06-20T07:39:35Z")

</div>

No, I didn’t export them. I understand now the reason why it didn’t work.

No dia 20/06/2018, às 02:28, jmert [julialang@discoursemail.com](mailto:julialang@discoursemail.com) escreveu:
