JuliaPy / PyPlot.jl

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

Cannot use PyPlot #18

Open ghost opened 11 years ago

ghost commented 11 years ago

Although I am able to install PyPlot, I get an error message when importing it into a Julia session:

julia> Pkg.update()
INFO: Initializing package repository /home/carlos/.julia.
INFO: Cloning METADATA from git://github.com/JuliaLang/METADATA.jl
INFO: Updating METADATA...
INFO: Computing changes...
INFO: No packages to install, update or remove.

julia> Pkg.add("PyPlot")
INFO: Cloning cache of PyPlot from git://github.com/stevengj/PyPlot.jl.git
INFO: Cloning cache of Color from git://github.com/JuliaLang/Color.jl.git
INFO: Cloning cache of PyCall from git://github.com/stevengj/PyCall.jl.git
INFO: Installing PyPlot v1.0.11
INFO: Installing Color v0.2.6
INFO: Installing PyCall v0.0.0
INFO: REQUIRE updated.

julia> using PyPlot
ERROR: PyError (PyImport_ImportModule) <type 'exceptions.AttributeError'>
AttributeError("'module' object has no attribute 'core'",)
File "/usr/local/lib/python2.7/dist-packages/matplotlib/__init__.py", line 129, in <module>
    from matplotlib.cbook import is_string_like
File "/usr/local/lib/python2.7/dist-packages/matplotlib/cbook.py", line 28, in <module>
    import numpy as np
File "/usr/local/lib/python2.7/dist-packages/numpy/__init__.py", line 137, in <module>
    import add_newdocs
File "/usr/local/lib/python2.7/dist-packages/numpy/add_newdocs.py", line 9, in <module>
    from numpy.lib import add_newdoc
File "/usr/local/lib/python2.7/dist-packages/numpy/lib/__init__.py", line 13, in <module>
    from polynomial import *
File "/usr/local/lib/python2.7/dist-packages/numpy/lib/polynomial.py", line 11, in <module>
    import numpy.core.numeric as NX

in pyerr_check at /home/carlos/.julia/PyCall/src/exception.jl:58
in pyimport at /home/carlos/.julia/PyCall/src/PyCall.jl:85
in include at boot.jl:238
in include_from_node1 at loading.jl:96
in reload_path at loading.jl:121
in require at loading.jl:50
at /home/carlos/.julia/PyPlot/src/PyPlot.jl:32

julia> 

How can I get PyPlot up and running?

I am running:

ghost commented 11 years ago

Anyone please help?

ghost commented 11 years ago

I was able to narrow down where the problem is coming from. I removed almost every Python package I had installed and reinstalled matplotlib (using pip) afterwards. This was fruitful as PyPlot worked after doing that. From that point I reinstalled my other Python packages (using pip) and kept on testing whether PyPlot would load normally and it did until I installed numpy using sudo pip install --upgrade numpy. PyPlot immediately stopped to load correctly after installing numpy and it immediately started to work again after removing numpy with sudo pip uninstall numpy. So maybe PyPlot is not playing too friendly with the newest version of numpy (1.7.1).

stevengj commented 11 years ago

Could be a PyCall bug, since PyCall uses NumPy directly; maybe it doesn't work with the latest NumPy? But what confuses me is that the error occurs while importing matplotlib.

Does importing matplotlib work in Python with the latest numpy on your system? Realize that matplotlib itself uses numpy, and you may have a version of matplotlib compiled only to work with the older numpy.

ghost commented 11 years ago

Well I removed the newest version because of PyPlot, but after reinstalling numpy 1.7.1 to confirm it appears that matplotlib does work, both in the python and ipython interpreter.