I am a self-taught QGIS user with low computer skills.

I run QGIS 2.10 on Ubuntu 15.10. I am trying to use Alexander Hajmal's tile_writer script (http://alephnull.net/software/gis/tile_writer.shtml). However, when I attempt to execute the script I get this message:

Traceback (most recent call last): File "", line 1, in File "/home/brian/tile_writer.0.2.1/tile_writer.py", line 64, in from globalmercator import GlobalMercator File "/usr/lib/python2.7/dist-packages/qgis/utils.py", line 478, in _import mod = _builtin_import(name, globals, locals, fromlist, level) ImportError: No module named globalmercator

I have globalmercator.py on my home directory along with tilewriter.py, in a folder named "tile_writer.0.2.1". When the script didn't work I tried to add the following two lines to my etc/environment file:


Unfortunately the results were still the same.

How do I properly set the path, or whatever else I am supposed to do?

closed as off-topic by gene, Paul, Fezter, John Powell, Mapperz Nov 16 '15 at 14:51

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions relating to general Information Technology, with no clear GIS component, are off-topic here, but can be researched/asked at Stack Overflow (software development), Super User (computing hardware and software) and Database Administrators (relational databases)" – gene, Paul, Fezter, John Powell, Mapperz
If this question can be reworded to fit the rules in the help center, please edit the question.


You don't need to fix the PYTHONPATH here, it is a pure Python PATH problem

import os 
working_directory = os.getcwd()

gives you the working directory. All Python files should be in this folder

>>> import os
>>> os.getcwd()
>>> import globalmercator

If you are not working in this folder, use sys.path.append

>>> import os
>>> os.getcwd()
>>> import sys
>>> import globalmercator
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named globalmercator
>>> sys.path.append("/Users/Shared/tile_writer.0.2.1")
>>> import globalmercator

If you really want to use a valid PYTHONPATH (same as sys.path.append)

$ export PYTHONPATH=/Users/Shared/tile_writer.0.2.1
$ python
 Python 2.7.10 (default, Jul 14 2015, 19:46:27) 
>>> import globalmercator

Not the answer you're looking for? Browse other questions tagged or ask your own question.