mapnik / python-mapnik

Python bindings for mapnik
GNU Lesser General Public License v2.1
157 stars 91 forks source link

installing "python setup.py install" OSError #199

Closed Ayrtonalec closed 5 years ago

Ayrtonalec commented 5 years ago

When I try to run setup.py with the command sudo python setup.py install I keep running into the following error:

Traceback (most recent call last):
  File "setup.py", line 114, in <module>
    lib_path = os.path.join(check_output([mapnik_config, '--prefix']),'lib')
  File "setup.py", line 20, in check_output
    output = subprocess.check_output(args)
  File "/usr/lib64/python2.7/subprocess.py", line 212, in check_output
    process = Popen(stdout=PIPE, *popenargs, **kwargs)
  File "/usr/lib64/python2.7/subprocess.py", line 390, in __init__
    errread, errwrite)
  File "/usr/lib64/python2.7/subprocess.py", line 1025, in _execute_child
    raise child_exception
OSError: [Errno 2] No such file or directory

Does anyone know what is exactly causing this and how to fix it?

The reason I'm going for this approach is that sudo python pip install mapnik end up with an import failure of mapnik. I'll also link the stack trace of this error in case if it could help the issue in any way. The traceback from import mapnik with the regular sudo python pip install mapnik is:

>>> import mapnik
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "mapnik.py", line 3, in <module>
    m = mapnik.Map(600,300) # create a map with a given width and height in pixels
AttributeError: 'module' object has no attribute 'Map'

I run the following versions: Python: Python 2.7.14 (default, May 2 2018, 18:31:34) OS: CentOS6 on AmazonAWS ec2 instance (editing the code in their cloud9) installed mapnik version: 3.0.0-pre (mapnik-config -v)

talaj commented 5 years ago

It seems like the setup script cannot find mapnik-config in PATH.

talaj commented 5 years ago

AttributeError: 'module' object has no attribute 'Map'

Don't you have mapnik.py file in the directory from where you do the import mapnik? Python then imports your mapnik.py instead of system mapnik module.

Ayrtonalec commented 5 years ago

AttributeError: 'module' object has no attribute 'Map'

Don't you have mapnik.py file in the directory from where you do the import mapnik? Python then imports your mapnik.py instead of system mapnik module.

First of all, thank you for the quick response! You were absolutely right there, rookie mistake. Still under the new year aftermath effect, I suppose. :(

Renamed the file and I still get the same error though, except not in import mapnik but after I have imported mapnik and try to use m = mapnik.Map(600,300). Stack trace:

Traceback (most recent call last):
  File "mapnik_server.py", line 1, in <module>
    import mapnik
  File "/home/ec2-user/environment/tile-server-s/temp/mapnik.py", line 3, in <module>
AttributeError: 'module' object has no attribute 'Map'

My file: (literally jus those two lines of code)

import mapnik

m = mapnik.Map(600,300) # create a map with a given width and height in pixels

Do you have any idea what might cause this?

talaj commented 5 years ago

I think it is still the same problem, it seems like it imports some /home/ec2-user/environment/tile-server-s/temp/mapnik.py.

Ayrtonalec commented 5 years ago

There was another file called mapnik.pyc indeed. Apparently, it is created when someone uses the test command:

python -c "import mapnik;print mapnik.__file__" # should return the path to the python bindings and no errors

It is working as it is supposed to now. Thank you for your help and the best wishes for 2019!