0

I need to use gdal2tiles with Anaconda 3 on Ubuntu 18.04. I've created the environment using:

conda create --name gisenv python=3.6

I've installed GDAL with:

conda install gdal

After this I've created a simple python script import gdal2tiles but I see this error message:

ModuleNotFoundError: No module named 'gdal2tiles'

I thought that using conda install gdal2tiles would solve the problem but I see this message:

Collecting package metadata (current_repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve. Collecting package metadata (repodata.json): done Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

  • gdal2tiles

Current channels:

To search for alternate channels that may provide the conda package you're looking for, navigate to

https://anaconda.org

and use the search bar at the top of the page.

How I can solve?

2

The python module gdal2tiles is not in the path by default

I'm able to import it using

conda create --name gisenv python=3.6
conda activate gisenv
conda install gdal

Then, running the following in python does work

import os
import sys

sys.path.insert(0, os.path.join(os.environ['CONDA_PREFIX'], 'bin'))
import gdal2tiles

I'm surprised you don't use the command line gdal2tiles.py instead of trying to run it through Python. Curious about your use case.

1
  • I'm learning python I preferred to share only the first line of a script inside a .py that use also gdal2tiles. – Massimiliano Moraca Feb 4 '20 at 18:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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