在Amazon Linux虚拟服务器上安装Python 2.7上的GDAL

我有一个t2.micro Amazon Linux实例正在运行。

Python 2.7.12已经预装了。 我想用Python安装GDAL。

我已经得到了gcc c ++和numpy的安装。

以下命令都不适用于我:

sudo yum install gdal-devel sudo yum install gdal sudo yum install python-gdal 

他们都引起了以下的消息。

 No package {PACKAGE_NAME} available. Error: Nothing to do 

我无法在Amazon Linux实例上运行apt-get。

也没有任何相关的SOpost为我工作。

我也跑了

 sudo easy_install GDAL 

这给了一个MemoryError如下:

 Searching for GDAL Reading https://pypi.python.org/simple/GDAL/ Best match: GDAL 2.2.1 Downloading https://pypi.python.org/packages/f2/c3/1cadfcae9a4330c3a68c41e3bc96a5d228883eec6ea3e2fc6321165b863c/GDAL-2.2.1.tar.gz#md5=4d78446b1053825a2d15b70730288b0f Processing GDAL-2.2.1.tar.gz Writing /tmp/easy_install-1VNr7G/GDAL-2.2.1/setup.cfg Running GDAL-2.2.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-1VNr7G/GDAL-2.2.1/egg-dist-tmp-q1jQCi Traceback (most recent call last): File "/usr/bin/easy_install", line 9, in <module> load_entry_point('setuptools==12.2', 'console_scripts', 'easy_install-2.7')() File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 2297, in main distclass=DistributionWithoutHelpCommands, **kw File "/usr/lib64/python2.7/distutils/core.py", line 151, in setup dist.run_commands() File "/usr/lib64/python2.7/distutils/dist.py", line 953, in run_commands self.run_command(cmd) File "/usr/lib64/python2.7/distutils/dist.py", line 972, in run_command cmd_obj.run() File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 393, in run self.easy_install(spec, not self.no_deps) File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 642, in easy_install return self.install_item(spec, dist.location, tmpdir, deps) File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 672, in install_item dists = self.install_eggs(spec, download, tmpdir) File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 857, in install_eggs return self.build_and_install(setup_script, setup_base) File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1085, in build_and_install self.run_setup(setup_script, setup_base, args) File "/usr/lib/python2.7/dist-packages/setuptools/command/easy_install.py", line 1071, in run_setup run_setup(setup_script, args) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 240, in run_setup raise File "/usr/lib64/python2.7/contextlib.py", line 35, in __exit__ self.gen.throw(type, value, traceback) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 193, in setup_context yield File "/usr/lib64/python2.7/contextlib.py", line 35, in __exit__ self.gen.throw(type, value, traceback) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 152, in save_modules yield saved File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 126, in __exit__ self._saved = UnpickleableException.dump(type, exc) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) File "/usr/lib/python2.7/dist-packages/setuptools/sandbox.py", line 110, in dump return cls.dump(cls, cls(repr(exc))) MemoryError 

它在EPEL储存库中。 尝试这个:

 sudo yum-config-manager --enable epel sudo yum install gdal-python sudo yum -y update sudo yum -y install make automake gcc gcc-c++ libcurl-devel proj-devel geos-devel cd /tmp curl -L http://download.osgeo.org/gdal/2.0.0/gdal-2.0.0.tar.gz | tar zxf - cd gdal-2.0.0/ ./configure --prefix=/usr/local --with-python make -j4 sudo make install sudo easy_install GDAL export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH" sudo ldconfig 

我能够得到这个工作在新的t2.micro运行亚马逊linux。 最后的输出需要根据你的需要在bash脚本或相关的地方永久保存。

在此之后,我能够from osgeo import gdal

您可以在/tmp/gdal-2.0.0文件夹中make clean ,以在完成时释放一些空间。

警告 – 建立花了很长一段时间t2.micro

我在我的EC2实例(m4.large)上有这个链接 ,它有Amazon Linux和python 2.7。 它完美的工作(我把Gdal 2.0.0更改为2.2.0)。 只要确保你有所有的依赖(即numpy和libgdal)。 让我知道如果你有任何问题!