JuliaPy / PyPlot.jl

Plotting for Julia based on matplotlib.pyplot
https://github.com/JuliaPy/PyPlot.jl
MIT License
476 stars 87 forks source link

R6034 #313

Closed jsschlosser closed 6 years ago

jsschlosser commented 7 years ago

Hello,

I have Julia versions 6.2 and 5.2. I have tried to create an ODE system solver using the DifferentialEquations package. I solved the ODE fine, but then I cannot seem to get the pyplot to work correctly. I have searched and tried to get this working, but nothing helps. Every time I try to use pyplot I get a runtime error R6034. Can anyone please tell me what I should do? I have tried any and all other options I could find.

Thank you,

Joseph Schlosser

stevengj commented 7 years ago

This was discussed in https://discourse.julialang.org/t/plot-problem/6067/4 and https://stackoverflow.com/questions/46399480/julia-runtime-error-when-using-pyplot ... there, people reported that

ENV["PYTHON"]=""
Pkg.build("PyCall")

fixed the problem

emenems commented 7 years ago

Switching to Anaconda\python.exe fixed this issue (I guess it has to do with the location of msvcr90.dll as discussed here)

# ENV["PYTHON"]="" # didn't help in my case
ENV["PYTHON"] = "E:\\Anaconda3\\python.exe"
Pkg.build("PyCall")
BoundaryValueProblems commented 6 years ago

I tried both ENV["PYTHON"]="" and ENV["PYTHON"]="C:\\Python27\\python.exe", but neither worked. The latter one generated the following warning and error messages. Thanks a lot for further help since I want to use pyplot in Plots in Windows machines. BVPs

WARNING: Couldn't initialize pyplot.  (might need to install it?)
INFO: To do a standard install of pyplot, copy and run this:

if !Plots.is_installed("PyPlot")
    Pkg.add("PyPlot")
InitError: Failed to import required Python module matplotlib.

For automated matplotlib installation, try configuring PyCall to use the Conda.jl package's Python "Miniconda" distribution within Julia. Relaunch Julia and run:
    ENV["PYTHON"]=""
    Pkg.build("PyCall")
before trying again.

The pyimport exception was: PyError (ccall(@pysym(:PyImport_ImportModule), PyPtr, (Cstring,), name)

The Python package matplotlib could not be found by pyimport. Usually this means
that you did not install matplotlib in the Python version being used by PyCall.

PyCall is currently configured to use the Python version at:

C:\Python27\python.exe

and you should use whatever mechanism you usually use (apt-get, pip, conda,
etcetera) to install the Python package containing the matplotlib module.

One alternative is to re-configure PyCall to use a different Python
version on your system: set ENV["PYTHON"] to the path/name of the python
executable you want to use, run Pkg.build("PyCall"), and re-launch Julia.

Another alternative is to configure PyCall to use a Julia-specific Python
distribution via the Conda.jl package (which installs a private Anaconda
Python distribution), which has the advantage that packages can be installed
and kept up-to-date via Julia.  As explained in the PyCall documentation,
set ENV["PYTHON"]="", run Pkg.build("PyCall"), and re-launch Julia. Then,
To install the matplotlib module, you can use `pyimport_conda("matplotlib", PKG)`,
where PKG is the Anaconda package the contains the module matplotlib,
or alternatively you can use the Conda package directly (via
`using Conda` followed by `Conda.add` etcetera).

) <type 'exceptions.ImportError'>
ImportError('No module named matplotlib',)

during initialization of module PyPlot
in pyplot at Plots\src\backends.jl:23
in #pyplot#278 at Plots\src\backends.jl:23
in backend at Plots\src\backends.jl:185
in _initialize_backend at Plots\src\backends\pyplot.jl:72
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:172
in pyimport_conda at PyCall\src\PyCall.jl:609
withenv("PYTHON" => "") do
    Pkg.build("PyPlot")
end

# now restart julia!
BoundaryValueProblems commented 6 years ago

Sorry, now it works! I had to install matplotlib by running python explicitly by:

python -mpip install -U matplotlib

It's good now so that it works now, yet I'm curious to know why the python.exe under ~/.julia/v0.6/Conda/deps/usr/ cannot be set as the default python.

stevengj commented 6 years ago

What error did you get from

ENV["PYTHON"]=""
Pkg.build("PyCall")

then re-launching Julia and doing using PyPlot?

emenems commented 6 years ago

If not setting ENV["PYTHON"] = "E:\\Anaconda3\\python.exe", but ENV["PYTHON"]="" instead, this Runtime Error pops-up after calling using PyPlot; plot([1,2,3])

Microsoft Visual C++ Runtime Library
Program:
C:\Users\myname\AppData\Local\Julia-0.6.0\bin\julia.exe

R6034
An application has made and attempt to load the C runtime library incorrectly.  
Please contact the application's support team for more information.
yha commented 6 years ago

I also get the same error when plotting with PyPlot (e.g. using PyPlot; plot(rand(10))), and it persists after running

ENV["PYTHON"]=""
Pkg.build("PyCall")

and restarting Julia. It's not a huge deal, since I can point Julia to the Anaconda python install instead, but is there a reason this issue was closed?

Corvu commented 6 years ago

I was unable to resolve it as well and used separate Anaconda as a workaround.

The issue looks related to https://github.com/JuliaPy/PyCall.jl/issues/87. It seems that earlier Julia had msvcrt.dll in its manifest as a dependency, while Python did not and used version that comes with Python distribution instead. The issue was resolved by deleting library from the manifest. Now it looks like the other way around, with Python having this dependency in its manifest.

thchr commented 6 years ago

Just seconding the issue noted above; I similarly got hit with the R6034 error on a fresh Julia install on Windows 10. The Conda install didn't play, despite multiple Pkg.build("PyCall") refreshes, various proposed settings for ENV["PYTHON"] or ENV["MPLBACKEND"]. Using a separate Anaconda install with ENV["PYTHON"] pointing to that install rather than the Conda install did end up working, however.

As far as I can tell, I didn't have any multiples of the msvcr90.dll in my path - if that's of any use.