Comments (7)
Getting to the likely root cause: Importing Image twice, possibly due to some difference in the paths that refer to it in subsequent import attempts (symbolic link?). Do you have more than one Python version installed? Is your '''PYTHONPATH''' in '''.bash_profile''' pointing to a single library? Are there multiple python libraries in the '''$PATH'''? Does the shared object exist in more than one path on the filesystem? I guess the import code should be as carefully written as your patch to '''tilestache-server.py'''. Considering that your patch is a useful improvement, correcting the root cause might not be necessary. I'll keep poking at this until I either get to the bottom of it or run out of time (probably the latter but hopefully the former).
from tilestache.
I just ran into this bug on my Mac using a Homebrew version of Python. It seems to be a well-known problem with two different ways to import PIL Image. Adding johtso's sys.modules patch to the top of my CGI and Gunicorn python config fixed the problem for me.
This problem occurs in other libraries: Django for instance. I believe the solution is to ensure that TileStache and all its related code only ever imports either Image
or PIL.Image
. Unfortunately it's not clear which one is correct. Here's a couple of Python sessions demonstrating the problem.
Python 2.7.4 (default, Apr 15 2013, 07:26:56)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.27)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> import Image
>>> sys.modules["Image"]
<module 'Image' from '/usr/homebrew/Cellar/python/2.7.4/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PIL/Image.pyc'>
>>> import PIL.Image
AccessInit: hash collision: 3 for both 1 and 1
Python 2.7.4 (default, Apr 15 2013, 07:26:56)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.27)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> import PIL.Image
>>> sys.modules["PIL.Image"]
<module 'PIL.Image' from '/usr/homebrew/lib/python2.7/site-packages/PIL/Image.pyc'>
>>> import Image
AccessInit: hash collision: 3 for both 1 and 1
from tilestache.
I'm hitting this same issue using a brew installed version of Python 2.7.5, but the fix proposed here results in
$ ./scripts/tilestache-server.py
Fatal Python error: PyThreadState_Get: no current thread
Abort trap: 6
$
The related fix proposed in #134 has no effect, I still get
AccessInit: hash collision: 3 for both 1 and 1
from tilestache.
@erictheise your problem is most likely related to the mapnik import. This happens when you have installed mapnik through homebrew, but are actually using the system python to import it. This was a very common error for our devs.
Check that the system python is not being used by doing something like (fyi, my virtualenv called indoor
is activated):
(indoor)[email protected] ~ $ python -c 'import sys;import pprint; pprint.pprint(sys.path)'
['',
'/usr/local/lib/python2.7/site-packages/distribute-0.6.40-py2.7.egg',
'/usr/local/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg',
'/usr/local/lib/python2.7/site-packages',
'/Users/rburhum',
'/Users/rburhum/.virtualenvs/indoor/lib/python27.zip',
'/Users/rburhum/.virtualenvs/indoor/lib/python2.7',
'/Users/rburhum/.virtualenvs/indoor/lib/python2.7/plat-darwin',
'/Users/rburhum/.virtualenvs/indoor/lib/python2.7/plat-mac',
'/Users/rburhum/.virtualenvs/indoor/lib/python2.7/plat-mac/lib-scriptpackages',
'/Users/rburhum/.virtualenvs/indoor/lib/python2.7/lib-tk',
'/Users/rburhum/.virtualenvs/indoor/lib/python2.7/lib-old',
'/Users/rburhum/.virtualenvs/indoor/lib/python2.7/lib-dynload',
'/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
'/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
'/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
'/usr/local/Cellar/python/2.7.5/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
'/Users/rburhum/.virtualenvs/indoor/lib/python2.7/site-packages',
'/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg-info',
'/usr/local/lib/python2.7/site-packages/wx-2.9.4-osx_cocoa']
(indoor)[email protected] ~ $
There should be no system python. If there is, you want to destroy that virtualenv and recreate it.
This is what I have in my ~/.bashrc to make sure the right virtualenv settings from homebrew is being used:
# Setting up the VirtualEnv
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python2.7
#export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages'
export PIP_VIRTUALENV_BASE=$WORKON_HOME
export PIP_RESPECT_VIRTUALENV=true
if [[ -r /usr/local/bin/virtualenvwrapper.sh ]]; then
source /usr/local/bin/virtualenvwrapper.sh
else
echo "WARNING: Can't find virtualenvwrapper.sh"
fi
export PYTHONPATH="/usr/local/lib/python2.7/site-packages:$PYTHONPATH"
from tilestache.
@NelsonMinar I cannot reproduce the errors using both of your examples
(indoor)[email protected] ~ $ python
Python 2.7.5 (default, May 28 2013, 14:33:04)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> import Image
>>> sys.modules["Image"]
<module 'Image' from '/Users/rburhum/.virtualenvs/indoor/lib/python2.7/site-packages/PIL/Image.pyc'>
>>> import PIL.Image
>>>
Second Example:
(indoor)[email protected] ~ $ python
Python 2.7.5 (default, May 28 2013, 14:33:04)
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> import PIL.Image
>>> sys.modules["PIL.Image"]
<module 'PIL.Image' from '/Users/rburhum/.virtualenvs/indoor/lib/python2.7/site-packages/PIL/Image.pyc'>
>>> import Image
>>>
from tilestache.
Belated thanks, @rburhum & @NelsonMinar. I was doing this on a machine that predates homebrew, plus the good doctor is not always correct in his prognoses. But Ragi's intuition was correct and it turns out that a boost library was linked against the system python as opposed to my brewed python.
from tilestache.
For the googlers, you can verify whether or not boost-python is causing problems by running:
brew list --verbose boost-python | grep dylib | xargs otool -L
If you end up seeing mentions of /System in the output that follows, you should do the following:
brew uninstall boost-python
brew install --build-from-source boost-python
Good luck!
from tilestache.
Related Issues (20)
- mbtiles apparently not working HOT 2
- werkzeug requirement should be optional HOT 1
- WebP Support
- make queries on different databases in tilestache
- Tilestache not serving Crossed Polygons
- Tag releases uploaded to PyPI
- can't have a MultiProvider with mvt tiles HOT 10
- tilestache-server seems to fail proxying https tile providers HOT 2
- TileStache offers a xyz services like tms services,not a wms server? HOT 1
- OSERROR encountered when requesting jpg tile outside of configured bounds HOT 2
- State of GDAL datasources HOT 1
- OSM Proxy missing Headers - HTTP Error 403: Forbidden
- Tilestache not delivering mbtiles generated with tippecanoe
- Website offline
- py3 compatibility? HOT 2
- FIX for cannot import name 'parse_qs' from 'cgi' ERROR in Tilestache/Mapnik/Ubuntu-20.04/Python-3.8 HOT 1
- Tilestache server error -> Unsupported operand type (on Debian 10)
- Core.Layer:getTileResponse needs to reset "format" with NoTileLeftBehind
- TileStache Abandoned? HOT 2
- Tiles with transparency outside image/BBOX with RGB images
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tilestache.