marceloprates / prettymaps

A small set of Python functions to draw pretty maps from OpenStreetMap data. Based on osmnx, matplotlib and shapely libraries.
GNU Affero General Public License v3.0
11.13k stars 524 forks source link

Large dependancies #16

Open lpointal opened 3 years ago

lpointal commented 3 years ago

Should advice to install in a virtual / conda environment, as it retrieve many dependancies which could break some beginners Python installation with different version of libs than those installed on their OS.

TaylorBurnham commented 3 years ago

I spent a few hours last night trying to get this to work on Windows so I could submit a PR with a Conda file but no luck, I ended up just building a Docker container to host it.

Dockerfile

FROM jupyter/scipy-notebook:33add21fab64
COPY --chown=${NB_UID}:${NB_GID} requirements.txt /tmp/
RUN python -m pip install --upgrade pip
RUN pip install --quiet --no-cache-dir git+https://github.com/abey79/vsketch#egg=vsketch
RUN pip install --quiet --no-cache-dir git+https://github.com/marceloprates/prettymaps.git
RUN fix-permissions "${CONDA_DIR}" && fix-permissions "/home/${NB_USER}"
ENTRYPOINT ["jupyter", "lab", "--ip=0.0.0.0", "--allow-root"]

requirements.txt

osmnx==1.0.1
tabulate==0.8.9
IPython==7.27.0

Build and run it using these commands.

docker build -t jupyter/jupyter-prettymaps .
docker run -it --rm -p 8888:8888 -v ${PWD}:/home/jovyan/work jupyter/jupyter-prettymaps:latest

It ain't perfect but it works. I've noticed no performance hit on my Windows 11 21H2 with WSL2 backing Docker, most of the "wait" is the built in throttling by osmnx to avoid overusing the public endpoints.

fuujiro commented 3 years ago
requirements.txt

can you share your docker-file or your container upload on docker hub? so much thx.

gonzalezhomar commented 3 years ago

I also tried to use it on a virtual enviroment using anaconda on windows, but it's still not working. By running the installation commands on the example notebook i get this errors:

Running command git clone -q https://github.com/marceloprates/prettymaps.git 'C:\Users\Homar\AppData\Local\Temp\pip-req-build-tk_icbql' warning: the following paths have collided (e.g. case-sensitive paths on a case-insensitive filesystem) and only one from the same colliding group is in the working tree:

'prints/Erbil.svg'
'prints/erbil.svg'
'prints/Palmanova.svg'
'prints/palmanova.svg'
ERROR: Command errored out with exit status 1:
 command: 'C:\Users\Homar\anaconda3\envs\pmaps\python.exe' -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Homar\\AppData\\Local\\Temp\\pip-install-l97cd83j\\fiona_5f3a41cf8f1a4a6585cea87c51afe04e\\setup.py'"'"'; __file__='"'"'C:\\Users\\Homar\\AppData\\Local\\Temp\\pip-install-l97cd83j\\fiona_5f3a41cf8f1a4a6585cea87c51afe04e\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\Homar\AppData\Local\Temp\pip-pip-egg-info-wwix2f0d'
     cwd: C:\Users\Homar\AppData\Local\Temp\pip-install-l97cd83j\fiona_5f3a41cf8f1a4a6585cea87c51afe04e\
Complete output (1 lines):
A GDAL API version must be specified. Provide a path to gdal-config using a GDAL_CONFIG environment variable or use a GDAL_VERSION environment variable.

And after that one: Running setup.py install for fiona: finished with status 'error'

     cwd: C:\Users\Homar\AppData\Local\Temp\pip-install-l97cd83j\fiona_7b103b5849164c159e9d0199502e4d11\
Complete output (1 lines):
A GDAL API version must be specified. Provide a path to gdal-config using a GDAL_CONFIG environment variable or use a GDAL_VERSION environment variable.
----------------------------------------

WARNING: Discarding https://files.pythonhosted.org/packages/a0/d9/6042aeb073d11341f7726de0586ff71c13117c34959dcf07bd4ee6d4b93e/Fiona-1.8.19.tar.gz#sha256=b9059e0b29c2e9e6b817e53f941e77e1aca7075f986005d38db307067b60458f (from https://pypi.org/simple/fiona/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. ERROR: Command errored out with exit status 1: command: 'C:\Users\Homar\anaconda3\envs\pmaps\python.exe' -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\Users\Homar\AppData\Local\Temp\pip-install-l97cd83j\fiona_8a2394a7196c4a979c64867415b66290\setup.py'"'"'; file='"'"'C:\Users\Homar\AppData\Local\Temp\pip-install-l97cd83j\fiona_8a2394a7196c4a979c64867415b66290\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(file) if os.path.exists(file) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\Homar\AppData\Local\Temp\pip-pip-egg-info-amvrgbev' cwd: C:\Users\Homar\AppData\Local\Temp\pip-install-l97cd83j\fiona_8a2394a7196c4a979c64867415b66290\ Complete output (1 lines): A GDAL API version must be specified. Provide a path to gdal-config using a GDAL_CONFIG environment variable or use a GDAL_VERSION environment variable.

The syntax of the command is incorrect. The syntax of the command is incorrect. 'wget' is not recognized as an internal or external command, operable program or batch file.

In the end, I tried just the imports and get ModuleNotFoundError: No module named 'prettymaps'

Can you share your docker file??

TaylorBurnham commented 3 years ago

My Dockerfile is in my comment above, but I realized I did not include the requirements file.

I've gotten GDAL working on Windows in the past but I had to compile it from source, you might have luck finding pre-compiled versions out there but I'm wary of those. If you have Docker available there should be no performance hit from using it since most of the wait time when generating are on API calls, and there's the added benefit that you're not cluttering your system with yet another conda or pip environment.

I just re-ran my steps and the only items in requirements.txt are below, all dependencies should be installed on lines 4 and 5 of the file.

osmnx==1.0.1
tabulate==0.8.9
IPython==7.27.0
Pranav4399 commented 2 years ago

Hey @gonzalezhomar Were you able to solve the GDAL API Version must be specified error in virtual environment ? I'm getting the same error in github actions.