# Not able to use PyPlot in the usual way

**URL:** <https://discourse.julialang.org/t/not-able-to-use-pyplot-in-the-usual-way/7016>\
**Category:** New to Julia\
**Tags:** juno, pyplot\
**Created:** [November 12, 2017, 12:09am UTC](https://discourse.julialang.org/t/not-able-to-use-pyplot-in-the-usual-way/7016 "2017-11-12T00:09:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Carsten](https://avatars.discourse-cdn.com/v4/letter/c/f14d63/32.png) [@Carsten](https://discourse.julialang.org/u/Carsten)\
**Post date:** [November 12, 2017, 12:09am UTC](https://discourse.julialang.org/t/not-able-to-use-pyplot-in-the-usual-way/7016/1 "2017-11-12T00:09:07Z")

</div>

I still have problems to apply PyPlot using JuliaPro v0.6.1.1. Prior to this version I used following lines after launching Juno:

> using PyPlot  
> x = linspace(0,2pi,200); y = sin.(x+2\*cos.(x));  
> plot(x,y)  
> The graph was then displayed in an extra window.

Now, using JuliaPro v0.6.1.1 this does not work anymore. Instead of the above lines I always have to apply the the following code:

> using PyCall  
> pygui(:tk) # or pygui() ## this line is necessary  
> using PyPlot  
> x = linspace(0,2pi,200); y = sin.(x+2\*cos.(x));  
> plot(x,y)

It seems that the first two lines are a prerequisite to use PyPlot at least in my JuliaPro installation

When I try to use a different Backup e.g. qt or qt5

> using PyCall  
> pygui(:qt) # or pygui(:qt5)  
> ENV[“PYTHON”]=“”  
> Pkg.build(“PyCall”)  
> using PyPlot  
> x = linspace(0,2pi,200); y = sin.(x+2\*cos.(x));  
> plot(x,y)

I‘ve got two error messages:  
The first one:

_This application failed to start because it could not find or_  
_load the Qt platform plugin 'windows‘ …._

and subsequently:

_Runtime Error_

\_R6034 \_  
_……._

Any suggestion are welcome

---

<div class="post-metadata">

**Author:** ![111](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/111/32/33971_2.png) [@111](https://discourse.julialang.org/u/111)\
**Post date:** [November 12, 2017, 2:01am UTC](https://discourse.julialang.org/t/not-able-to-use-pyplot-in-the-usual-way/7016/2 "2017-11-12T02:01:45Z")

</div>

What’s the result of “versioninfo()”  
In my case, i use JuliaPro 0.6.0+MKL in manjaro, I always got a “segmentation fault” when plotting with PyPlot. I set the python environment as “my/anaconda3.6/bin/python” or “” and rebuilt the PyCall and PyPlot packages. Problem was not solved. After a lot of time, I just gave up, and installed two version of Julia in my computer: JuliaPro 0.6.0+MKL and Julia 0.6.1.

---

<div class="post-metadata">

**Author:** ![Carsten](https://avatars.discourse-cdn.com/v4/letter/c/f14d63/32.png) [@Carsten](https://discourse.julialang.org/u/Carsten)\
**Post date:** [November 13, 2017, 2:41pm UTC](https://discourse.julialang.org/t/not-able-to-use-pyplot-in-the-usual-way/7016/3 "2017-11-13T14:41:42Z")

</div>

@111 Thank you for your reply. I did not find any information in the versionifo()

> Julia Version 0.6.1  
> Commit 0d7248e2ff\* (2017-10-24 22:15 UTC)  
> Platform Info:  
> OS: Windows (x86\_64-w64-mingw32)  
> CPU: Intel(R) Core™ i5-4200U CPU @ 1.60GHz  
> WORD\_SIZE: 64  
> BLAS: libopenblas (USE64BITINT DYNAMIC\_ARCH NO\_AFFINITY Haswell)  
> LAPACK: libopenblas64\_  
> LIBM: libopenlibm LLVM: libLLVM-3.9.1 (ORCJIT, haswell)

with respect to my problem.

Meanwhile I un-installed and re-installed JuliaPro-0.6.1.1. After launching Juno the following lines are entered:

> Pkg.update() # ok
> 
> ENV[“PYTHON”]=“”  
> Pkg.build(“PyCall”) # ok
> 
> using PyPlot

_InitError: PyError (ccall(@pysym(:PyImport\_ImportModule), PyPtr, (Cstring,), name)_  
_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. ) \<type ‘exceptions.ImportError’\> ImportError(‘No module named mpl\_toolkits.mplot3d’,) during initialization of module PyPlot_  
_in require at base\loading.jl:405_  
\_in _require at base\loading.jl:464_  
\_in _require\_from\_serialized at base\loading.jl:200_  
\_in _include\_from\_serialized at base\loading.jl:157_  
_in **init** at PyPlot\src\init.jl:205_  
_in pyimport at PyCall\src\PyCall.jl:374_  
_in macro expansion at PyCall\src\exception.jl:81_   
_in pyerr\_check at PyCall\src\exception.jl:61_   
_in pyerr\_check at PyCall\src\exception.jl:56_

As suggested in the error message I tried

> using PyCall  
> pyimport\_conda(“mpl\_toolkits.mplot3d”, “mpl\_toolkits”)

_PyObject \<module ‘mpl\_toolkits.mplot3d’ from 'C:\JuliaPro-0.6.1.1\pkgs-0.6.1.1\v0.6\Conda\deps\usr\lib\site-packages\mpl\_toolkits\mplot3d\_init_.pyc’\>\_

then

> using PyPlot  
> x = linspace(0,2pi,200); y = sin.(x+2\*cos.(x));  
> plot(x,y)

I’ve got the same error pop-up windows as described above.

> This application failed to start because it could not find or  
> load the Qt platform plugin 'windows‘ ….

and subsequently:

> Runtime Error  
> \_R6034 \_  
> …….

I have no idea at all how to resolve this problem? Any hint are highly wellcome!

---

<div class="post-metadata">

**Author:** ![Carsten](https://avatars.discourse-cdn.com/v4/letter/c/f14d63/32.png) [@Carsten](https://discourse.julialang.org/u/Carsten)\
**Post date:** [November 13, 2017, 4:17pm UTC](https://discourse.julialang.org/t/not-able-to-use-pyplot-in-the-usual-way/7016/4 "2017-11-13T16:17:22Z")

</div>

Finally I did it.

I installed Ananacoda3 and execute

ENV[“PYTHON”] = “c:\Users\Carsten\Anaconda3\python.exe”  
Pkg.build(“PyCall”)

after closing Juno and re-launching I insert

using PyPlot  
x = linspace(0,2pi,200); y = sin.(x+2\*cos.(x));  
plot(x,y)

things works at expected.  
In addition the Backend changed from :tk to :qt5 which was in the beginning not possible.
