# Call Python functions from Julia / Lorenz Attractor Example

**URL:** https://discourse.julialang.org/t/call-python-functions-from-julia-lorenz-attractor-example/8905
**Category:** General Usage
**Tags:** question, package, plotting
**Created:** [February 7, 2018, 6:39pm UTC](https://discourse.julialang.org/t/call-python-functions-from-julia-lorenz-attractor-example/8905 "2018-02-07T18:39:39Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![burfel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/burfel/32/3314_2.png) [@burfel](https://discourse.julialang.org/u/burfel)
#### Post date: [February 7, 2018, 6:39pm UTC](https://discourse.julialang.org/t/call-python-functions-from-julia-lorenz-attractor-example/8905/1 "2018-02-07T18:39:39Z")

</div>

Hello,

I was wondering how I best get Python functions running in Julia.

The Lorenz attractor example in  
[http://docs.juliaplots.org/latest/](http://docs.juliaplots.org/latest/)  
isn’t working for me. The error message I get is

_The Python package mpl\_toolkits.mplot3d could not be found by pyimport. Usually this means_  
_that you did not install mpl\_toolkits.mplot3d in the Python version being used by PyCall._  
_PyCall is currently configured to use the Julia-specific Python distribution_  
_installed by the Conda.jl package. To install the mpl\_toolkits.mplot3d module, you can_  
_use `pyimport_conda("mpl_toolkits.mplot3d", PKG)`, where PKG is the Anaconda_  
_package the contains the module mpl\_toolkits.mplot3d, or alternatively you can use the_  
_Conda package directly (via `using Conda` followed by `Conda.add` etcetera)._  
_Alternatively, if you want to use a different Python distribution on your_  
_system, such as a system-wide Python (as opposed to the Julia-specific Python),_  
_you can re-configure PyCall with that Python. As explained in the PyCall_  
_documentation, set ENV[“PYTHON”] to the path/name of the python executable_  
_you want to use, run Pkg.build(“PyCall”), and re-launch Julia._

I would be happy to get it running and reproduce the plot.

Any thoughts?

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [February 7, 2018, 7:12pm UTC](https://discourse.julialang.org/t/call-python-functions-from-julia-lorenz-attractor-example/8905/2 "2018-02-07T19:12:37Z")

</div>

Use a backend that’s not PyPlot. I would start with the tutorial.

[http://docs.juliaplots.org/latest/tutorial/](http://docs.juliaplots.org/latest/tutorial/)

---

<div class="post-metadata">

### Author: ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)
#### Post date: [February 7, 2018, 7:14pm UTC](https://discourse.julialang.org/t/call-python-functions-from-julia-lorenz-attractor-example/8905/3 "2018-02-07T19:14:19Z")

</div>

You might find a solution [here](https://discourse.julialang.org/t/error-installing-pyplot-the-python-package-mpl-toolkits-mplot3d-could-not-be-found-by-pyimport/6372/13). Maybe the very last one from stevengj.

EDIT: As @ChrisRackauckas mentioned, at least for beginners, PyPlot is probably not the best package for plotting in Julia as one can easily run into installation problems.

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [February 7, 2018, 7:20pm UTC](https://discourse.julialang.org/t/call-python-functions-from-julia-lorenz-attractor-example/8905/4 "2018-02-07T19:20:00Z")

</div>

> [@carstenbauer](#):
>
> You might find a solution here. Maybe the very last one from stevengj.

Ehh, I would still just try to avoid Python packages. They seem so unpredictable and tough to install. Using GR or Plotly avoids Python and thus avoids all of the issues that Conda/pip have.

---

<div class="post-metadata">

### Author: ![carstenbauer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/carstenbauer/32/4981_2.png) [@carstenbauer](https://discourse.julialang.org/u/carstenbauer)
#### Post date: [February 7, 2018, 7:39pm UTC](https://discourse.julialang.org/t/call-python-functions-from-julia-lorenz-attractor-example/8905/5 "2018-02-07T19:39:28Z")

</div>

> [@ChrisRackauckas](#):
>
> Ehh, I would still just try to avoid Python packages. They seem so unpredictable and tough to install.

I don’t disagree that one can easily run into installation problems with PyPlot and didn’t make a recommendation. My link is simply supposed to help him and anyone who wants to use PyPlot (maybe for a good reason).

(BTW: I almost exclusively use PyPlot for all my work because I know matplotlib inside out and in my eyes there is no pure Julia equivalent yet.)

---

<div class="post-metadata">

### Author: ![burfel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/burfel/32/3314_2.png) [@burfel](https://discourse.julialang.org/u/burfel)
#### Post date: [February 8, 2018, 5:49pm UTC](https://discourse.julialang.org/t/call-python-functions-from-julia-lorenz-attractor-example/8905/6 "2018-02-08T17:49:19Z")

</div>

It seems to run on some computers. But the error message I usually get on my computer is

> LoadError:  
> (::Atom.##110#114{String,String})() at eval.jl:104  
> withpath(::Atom.##110#114{String,String}, ::String) at utils.jl:30  
> withpath(::Function, ::String) at eval.jl:38  
> didWriteToREPL(::Atom.##109#113{String,String}) at repl.jl:129  
> hideprompt(::Atom.##109#113{String,String}) at repl.jl:65  
> macro expansion at eval.jl:99 [inlined]  
> (::Atom.##108#112{Dict{String,Any}})() at task.jl:80

most of the time some error in _utils.jl_

Is there anything I can do about it?
