holoviz / geoviews

Simple, concise geographical visualization in Python
http://geoviews.org
BSD 3-Clause "New" or "Revised" License
577 stars 75 forks source link

Pip installation? #33

Closed openp2pdesign closed 6 years ago

openp2pdesign commented 7 years ago

Is there any way to install this with pip, without conda?

philippjfr commented 7 years ago

Currently installing the required cartopy dependency is a bit of a pain because you need a specific dev build, which is why I didn't release to PyPI yet. I'd be happy to do so though, just have to be clear about the cartopy requirement.

openp2pdesign commented 7 years ago

Thanks for the quick reply! With pip install git+https://github.com/ioam/geoviews.git the installation is successful, cartopy as well (OSX El Capitan, Python installed with brew) but the notebooks do not work...

philippjfr commented 7 years ago

but the notebooks do not work...

Any specific error messages?

openp2pdesign commented 7 years ago

No error messages for geoviews, but its import stalls (the Python icon keeps loading but with CPU at 0% and I have to force quit it, and then the kernel of the notebook dies or python crashes completely).

I also get this with iris, but it seems to be unrelated I'd say, the normal geoviews import stalls:

AttributeError                            Traceback (most recent call last)
<ipython-input-6-7dbf502d20a9> in <module>()
----> 1 iris.FUTURE.strict_grib_load = True
      2 get_ipython().magic(u"output widgets='live' max_frames=1000   # Plot data on request")
      3 get_ipython().magic(u'opts Image {+framewise} Contours {+framewise}')

AttributeError: 'module' object has no attribute 'FUTURE'
philippjfr commented 7 years ago

We don't actually depend on iris, so unless you need it try uninstalling it. It's possible that iris is clashing with your cartopy install causing geoviews to crash when it tries to import some parts of iris.

openp2pdesign commented 7 years ago

Great! It seems to be loading perfectly now without iris. Are there any notebook without it so that I can test geoviews?

philippjfr commented 7 years ago

Are there any notebook without it so that I can test geoviews?

None of the notebooks depend on iris now, as I converted all the examples to xarray, so you should be good to go. I'll get the PyPI upload up soon, which will not depend on iris at all.

openp2pdesign commented 7 years ago

Ok, I tried with the example from http://geo.holoviews.org/, but I get this (and no error message on the terminal):

screen shot 2016-09-08 at 19 34 25

philippjfr commented 7 years ago

Okay, that sounds like it is a cartopy issue after all. Until there's a new cartopy release I can only really recommend getting the latest dev version from conda-forge.

openp2pdesign commented 7 years ago

Ok, many thanks. From the terminal it seems to be working (I don't know how to save the layout though), so probably there are also some conflict with Jupyter.

Python 2.7.12 (default, Jun 29 2016, 14:05:02) 
[GCC 4.2.1 Compatible Apple LLVM 7.3.0 (clang-703.0.31)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import holoviews as hv
>>> import geoviews as gv
>>> import geoviews.feature as gf
>>> import xarray as xr
>>> from cartopy import crs
>>> test = (gf.ocean + gf.land + gf.ocean * gf.land * gf.coastline * gf.borders).cols(3)
>>> print test
<Layout Layout01100>
philippjfr commented 7 years ago

From the terminal it seems to be working (I don't know how to save the layout though), so probably there are also some conflict with Jupyter.

In the terminal it doesn't try to render the plot, when you execute that cell in the notebook it will automatically render that object for you, which probably ends up calling into cartopy (or one of its C dependencies) causing python to crash.

philippjfr commented 7 years ago

I don't know how to save the layout though.

We're currently lacking in documentation on that front, but here's a quick overview:

backend = 'matplotlib' # or 'bokeh'
renderer = hv.Store.renderers[backend]

# Save rendered plot to file.
renderer.save(obj, filename)

# Get plot object
plot = renderer.get_plot(obj)
plot.initialize_plot()
plot.state # Returns matplotlib figure or bokeh plot object 

# Export plot as static html 
html = renderer.static_html(obj)

# Supply custom template for html
template = """
<html>
  <head>
    {css}
    {js}
  </head>
  <body>
    {html}
  </body>
</html>
"""
html = renderer.static_html(obj, template=template)

Until you've got a hold of the cartopy dev version I suspect none of this will work for you though.

openp2pdesign commented 7 years ago

Thanks. I tried to install cartopy with pip install git+https://github.com/SciTools/cartopy.git(is this the dev version? or where it is?) but it does not work either...

philippjfr commented 7 years ago

I'm fairly sure it's down to your version of proj4, which you get automatically with conda, but you will have to build manually if you're using pip. Have a look at the cartopy install instructions.

openp2pdesign commented 7 years ago

Proj: I have Rel. 4.9.2, 08 September 2015, installed with brew

philippjfr commented 7 years ago

And you're still seeing the same crashes as before? If you tell me what platform you're on I'll try to replicate your issues.

philippjfr commented 7 years ago

I've just looked at the cartopy conda-forge feedstock, which also seems to require a very specific version of geos, (see here), namely geos 3.4.*. Could that be it?

openp2pdesign commented 7 years ago

I tried with pip install git+https://github.com/SciTools/cartopy.git@v0.14.x (dev branch?), same problem. But maybe it's related to this: https://github.com/SciTools/cartopy/issues/738

openp2pdesign commented 7 years ago

... I have geos 3.5.0, again installed with Brew (Mac, El Capitan, Python installed with brew)

philippjfr commented 7 years ago

Sounds likely, and as usual pelson brings the solution, according to him it relates to Toblerity/Shapely#177, which causes shapely to link to the wrong version of geos. I have no good suggestions except trying to build shapely from scratch or using conda.

jbednar commented 7 years ago

This all sounds exactly why people use conda. :-)

openp2pdesign commented 7 years ago

Never had this problem! I tried with previous versions of geos, they break too many things and it does not work. I'll wait for the next version of cartopy/geoviews then

jbednar commented 7 years ago

I guess as package maintainers, we mainly hear from people with problems, and so as far as we can tell, everyone not using conda has problems with getting package versions to match. :-) But we hear that far less often from people using conda. Hopefully the versions will sort themselves out soon!

ispmarin commented 7 years ago

Any news on pip side? We could work with a fixed version of all libraries (as it was on the start of numpy) and use pip to install them. On Windows this would be a huge help.

philippjfr commented 7 years ago

I'll try to get a PyPI release up this weekend.

gilgamezh commented 7 years ago

Hi! I want to use this lib but I can't install conda. Any news on this issue? thanks!

jbednar commented 7 years ago

I'm still dubious about how well this will work in practice, given the non-Python dependencies of cartopy, but presumably we're no longer relying on a specific dev build of cartopy as mentioned above. So, @philippjfr, do you want to make a PyPI release of the current code? We're gearing up for a new HoloViews release in the next week or so, so maybe it would be better to wait for that.

kevhill commented 7 years ago

Hello, I'd also like to put a vote in for getting a pip-based install working, even if it does require a prior cartopy install. This isn't so uncommon for some python libs such as sqlalchemy. And if you are real nice you can just include some good trys before the imports and give some friendly error messages.

In trying to DIY it on OSX I did the following:

from the this blog post about installing cartopy on osx:

brew install geos
brew install proj

#needed to install cartopy as root
sudo pip install cartopy

Then trying to install geoviews via the github repo I hit this error:

AttributeError: module 'pandas' has no attribute 'computation'

Looks like this is related to a change in pandas 0.20. I'd suggest either updating the import statement, or setting an explicit limit on the pandas version in your setup.py

Anyway, I don't need any of the newest pandas features so I just did: pip install 'pandas<0.20' the quotes are needed for bash not to freak out

Then you should be gtg pip install git+https://github.com/ioam/geoviews.git

philippjfr commented 7 years ago

@kevhill The pandas error you encountered is likely due to an outdated version of dask. Would you mind updating dask and reporting back?

kevhill commented 7 years ago

looks like it is fixed in later dask versions https://stackoverflow.com/questions/43833081/attributeerror-module-object-has-no-attribute-computation

So maybe just set that req in the setup.py?

philippjfr commented 7 years ago

Dask is only an optional dependency for HoloViews and GeoViews. Did you already have it installed?

kevhill commented 7 years ago

I did. Not exactly sure from where as I use docker rather than virtaulenv when I want to isolate things... anyway it sounds like that is a small edge case you guys don't need to worry about. Thanks for the help

philippjfr commented 6 years ago

A pip package is finally up: https://pypi.org/project/geoviews/