PyPlot.jl icon indicating copy to clipboard operation
PyPlot.jl copied to clipboard

import PyPlot fails

Open jheinen opened this issue 10 years ago • 5 comments
trafficstars

Hi,

I have problems importing PyPlot on different CentOS 7 and Fedora 20 machines:

julia> import PyPlot
Warning: error initializing module PyPlot:
PyCall.PyError(msg=":PyImport_ImportModule", T=PyCall.PyObject(o=0x0000000001d86520), val=PyCall.PyObject(o=0x000000000a5b1e18), traceback=PyCall.PyObject(o=0x0000000000000000))

Importing PyCall (only) works fine:

julia> import PyCall
julia> PyCall.pyinitialize()

Any idea how to fix the problem?

Regards, Josef

jheinen avatar Jun 26 '15 15:06 jheinen

What happens if you manually do:

import PyCall
@pyimport matplotlib.pyplot as plt

?

stevengj avatar Jun 26 '15 18:06 stevengj

Here is the result:

julia> import PyCall
julia> @PyCall.pyimport matplotlib.pyplot as plt
ERROR: PyError (:PyImport_ImportModule) <type 'exceptions.ImportError'>
ImportError('No module named matplotlib.pyplot',)

 in pyerr_check at /usr/local/lib/julia/v0.3/PyCall/src/exception.jl:58
 in pyimport at /usr/local/lib/julia/v0.3/PyCall/src/PyCall.jl:91

My mistake; the default Python interpreter did not have matplotlib installed - sorry.

I corrected the path, but now I get an import error for the module 'site':

ImportError: No module named site

Importing 'site' in Python works fine.

jheinen avatar Jun 26 '15 19:06 jheinen

Are you using Enthought Canopy? If so, this is due to stevengj/PyCall.jl#42 ... I would recommend Anacona Python.

stevengj avatar Jun 28 '15 11:06 stevengj

I am using our "own" Python distribution, because we have much more packages installed than provided by Canopy or Anaconda. But, Anaconda is also installed on all of our desktops and it works. Nevertheless, I want to find out why the site package cannot be found (with our Python distribution) ...

jheinen avatar Jun 30 '15 15:06 jheinen

Basically, my understanding is that that error means that some kind of path is not being set up correctly (when we initialize python via libpython) that is set when you run the python executable....

stevengj avatar Jun 30 '15 18:06 stevengj