I need to import osgeo.ogr
module to virtualenv
python program.
Global python has this module:
user@ubuntu:~/$ python
Python 2.7.8 (default, Oct 20 2014, 15:05:19)
[GCC 4.9.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import osgeo
>>>
But into virtualenv (without --no-site-packages):
user@ubuntu:~$ temp/bin/python
Python 2.7.8 (default, Oct 20 2014, 15:05:19)
[GCC 4.9.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import osgeo
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named osgeo
What is the reason for this behavior?
Problem is solved in this way:
(VIRTUAL_ENV)user@ubuntu:~$ pip install --no-install GDAL==1.11.2
1.11.2 because my version GDAL is 1.11.2:
(VIRTUAL_ENV)user@ubuntu:~$ gdal-config --version
1.11.2
next:
(VIRTUAL_ENV)user@ubuntu:~$ cd ~/.virtualenvs/VIRTUAL_ENV/build/GDAL/
(VIRTUAL_ENV)user@ubuntu:~/.virtualenvs/VIRTUAL_ENV/build/GDAL$ python setup.py build_ext --include-dirs=/usr/include/gdal/
(VIRTUAL_ENV)user@ubuntu:~/.virtualenvs/bamap/build/GDAL$ pip install --no-download GDAL
--include-dirs=/usr/include/gdal/
for me is correct. GDAL was installed with Quantum GIS in my system. If you will build GDAL manually paths may be others. Full version:
python setup.py build_ext --gdal-config=/YOUR_PATH/bin/gdal-config --library-dirs=/YOUR_PATH/gdal/VERSION_GDAL/lib --libraries=gdal --include-dirs=/YOUR_PATH/gdal/VERSION_GDAL/include
Details may find here.