windows环境下安装Python的Rtree包

python提供的一个第三方包Rtree包能够实现R树查询、删除、增添的各种操作。然而版主在windows环境 (win 10, python3.5)下安装Rtree包的时候出现了问题。直接在cmd中输入pip install Rtree后,会出现一下错误:

Collecting Rtree
  Using cached Rtree-0.8.2.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\dellpc\AppData\Local\Temp\pip-build-zq00u5gn\Rtree\setup.py", line 4, in <module>
        import rtree
      File "C:\Users\dellpc\AppData\Local\Temp\pip-build-zq00u5gn\Rtree\rtree\__init__.py", line 1, in <module>
        from .index import Rtree
      File "C:\Users\dellpc\AppData\Local\Temp\pip-build-zq00u5gn\Rtree\rtree\index.py", line 6, in <module>
        from . import core
      File "C:\Users\dellpc\AppData\Local\Temp\pip-build-zq00u5gn\Rtree\rtree\core.py", line 101, in <module>
        raise OSError("could not find or load spatialindex_c.dll")
    OSError: could not find or load spatialindex_c.dll

如图所示:

当然,这个错误并不是版主没有使用pip3导致的,错误提示是少了spatialindex_c.dll这个文件。于是版主顺藤摸瓜,发现Rtree包是基于libspatialindex开发的,在安装Rtree之前必须先安装libspatialindex。关于libspatialindex,除了官网的英文外,这里有一个中文翻译过来的介绍:http://blog.csdn.net/ljz2173/article/details/46009573,不再多说。

于是版主又傻乎乎的去安装libspatialindex,但是开发这个libspatialindex的大神似乎并不喜欢windows,官网上只给了十分简要的安装说明,不过基本等于没说呀,大概意思是自己去找个编译器编译后使用吧。。。版主又借助在海外的优势,四处google怎样在windows下安装libspatialindex,找了半天全是国外网友的疑问,却没人回答......看来大部分人都是用的Linux,版主这么小白还用windows简直就是错误......国内网友似乎也无人问津这个问题。找了半天似乎只有国外一个大神成功了,不过我按照他的步骤试了很久,还是不行。这里还是把地址贴出来,仅供参考:

http://lists.gispython.org/pipermail/spatialindex/2012-December/000336.html,有兴趣有时间的同学可以一试

其实!其实!其实!哪里会有那么多麻烦事...发现了另一个Rtree官网的介绍,这里 http://toblerity.org/rtree/install.html#windows,看最下边win那里,“The Windows DLLs of libspatialindex are pre-compiled in windows installers that are available from PyPI. Installation on Windows is as easy as:”

这明明就是说win版本的,这个Dll文件已经预编译进去了呀!!!根本不需要自己去装libspatialindex......

下边正式说安装步骤,废话有点多了:

1. 这里 http://www.lfd.uci.edu/~gohlke/pythonlibs/#rtree 下载对应版本的Rtree的whl安装包,注意是python2.7还是3.5,注意电脑是32还是64位。可以放在电脑任意位置

2. 确保电脑里已经安装了python中wheel这个包,没有的话这个可以直接在cmd中输入pip install wheel安装

3. 打开cmd,输入pip install E:\软件安装包\Rtree-0.8.2-cp35-cp35m-win_amd64.whl,这个E盘是我存放Rtree的whl安装包的位置,自己安装的时候根据具体情况改一下即可。

然后两秒安装成功。

此时版主不知是该笑还是该哭,只觉得自己笨的要死...

不过,至今也没找到怎样正确在windows下安装libspatialindex的方法,还请大神指教。

顺便啰嗦一句吧,Linux安装libspatialindex的步骤大概如下:

https://github.com/libspatialindex/libspatialindex/wiki/1.-Getting-Started

鉴于国内github可能被墙,顺便也贴过来吧:

This tutorial will help you to get started with libspatialindex using C++ on linux. The following code is run on Ubuntu 12. If you are using windows the installation may be different. First install some prerequisites please enter the following into terminal. You may very well already have these installed.

sudo apt-get update
sudo apt-get install curl
sudo apt-get install g++
sudo apt-get install make

Now we download and install the library. It doesn‘t matter what directory you download this in. Please note the version number, you can check if there are more recent versions in the download page here http://download.osgeo.org/libspatialindex/ . Now enter the following into your terminal:

curl -L http://download.osgeo.org/libspatialindex/spatialindex-src-1.8.5.tar.gz | tar xz
cd spatialindex-src-1.8.5
./configure
make
sudo make install
sudo ldconfig

libspatialindex should now be installed on your system. Let‘s try to make a small c++ program to test this. Create the file tutorial1.cpp somewhere and enter the following:

#include <iostream>
#include <spatialindex/capi/sidx_api.h>
using namespace std;
using namespace SpatialIndex;

int main(int argc, char* argv[])
{
    char* pszVersion = SIDX_Version();
    fprintf(stdout, "libspatialindex version: %s\n", pszVersion);
    fflush(stdout);
    free(pszVersion);
}

Now let‘s compile the code. Type the following into the console. Please note -std=c++0x makes it compile into C++11, although not required here it will be used in later examples.

g++ -std=c++0x tutorial1.cpp -lspatialindex_c -lspatialindex -o tutorial1

Now run the program:

./tutorial1

and it should output the following:

libspatialindex version: 1.8.5
时间: 2024-08-25 03:56:15

windows环境下安装Python的Rtree包的相关文章

从零开始Windows环境下安装python+tensorflow

从零开始Windows环境下安装python+tensorflow 2017年07月12日 02:30:47 qq_16257817 阅读数:29173 标签: windowspython机器学习tensorflowAnaconda 更多 个人分类: machine-learning 前言 安装环境 tensorflow Anaconda 安装步骤 1.安装Anaconda 2.安装tensorflow 3.测试是否安装成功 总结 前言 本文介绍在Windows平台下,使用Anoconda简单安

Python Windows环境下安装Python集成开发环境 学习之路(一)

一.安装下载安装 Python https://www.python.org/ 全部下一步,直接Finish  PyCharm http://www.jetbrains.com/pycharm/ 全部下一步,直接Finish

windows环境下安装python的mysqldb模块

1. 安装数据库mysql 安装方式可参照 2. 安装MySQLdb 这一步,有两种安装方式A. 安装已编译好的版本(一分钟)B. 从官网下,自己编译安装(介个-..半小时到半天不等,取决于你的系统环境以及RP) 若是系统32位的,有c++编译环境的,自认为RP不错的,可以选择自己编译安装若是系统64位的,啥都木有的,建议下编译版本 2.1安装已编译版本:http://www.codegood.com/downloads根据自己系统下载,双击安装然后import MySQLdb,查看是否成功 我

在Windows环境下安装mod_dav

问题 如何在已行的1.3版本的Apachc服务器上安装mod_dav来启用WebDAV功能? 解决方法 Apache2.0版本把mod_dav作为一个标准的模块,因此你不需要下载及编译安装它. 从http://webdav.arg/nwd/win32获取Windows下的mod_dav包并解包.确认你的Apache服 务器是否在ServerRoot目录下安装了xmlparse.dll以及xmJtok.dll文件,如果这两个文件不存在, 则查找Apache整个目录并拷贝他们到ServerRoot下

【Python】如何在Windows操作系统下安装Python和Networkx

Networkx是一套基于Python的多种网络构造库.因为之前没有学过Python,因此一点点上手,这一篇讲一讲如何在Windows环境下安装Python2.7和Networkx. 首先要澄清一下,如果是想深入系统学习Python的同学,还是尽早换Linux系统,因为Windows底下的库安装非常麻烦:而Linux底下只需要运行命令行(Terminal): sudo apt-get install python-matplotlib 就可以了. 由于仅仅是使用Networkx构造数据的关系,以

4.1. 如何在Windows环境下开发Python

4.1. 如何在Windows环境下开发Python 4.1. 如何在Windows环境下开发Python 4.1.1. Python的最原始的开发方式是什么样的 4.1.1.1. 找个文本编辑器,新建个.py文件,写上Python代码 4.1.1.2. 打开Windows的cmd,并且切换到对应的python脚本所在目录 4.1.1.2.1. 方法1:手动打开cmd,并cd到对应路径 4.1.1.2.2. 方法2:通过Notepad++的Open current dir cmd 4.1.1.3

Windows 环境下运用Python制作网络爬虫

import webbrowser as web import time import os i = 0 MAXNUM = 1 while i <= MAXNUM: web.open_new_tab('要刷的网络地址') os.system('taskkill /F /IM 浏览器文件名(chrome.exe)') i += 1 else: print 'happly day!' 代码和简单只要一个第三方的函数和调用系统的文件就OK了.记住给要刷的次数定值,不然电脑就不好受了! Windows

windows 环境下安装wampserver2.5 64位

windows 环境下安装wampserver2.5 64位 出现的问题如下: 1.安装成功后修改mysql root 密码 (开始密码默认为空) 1.打开 mysql控制台 2.use mysql 3.update user set password=password(新密码) where user='root'; 4.flush privileges; (使修改的密码生效) 5.quit 退出控制台 2.配置apache 单IP 多站点 (开启虚拟机访问多站点) 1.找到httpd.conf

在windows环境下安装redis和phpredis的扩展

在windows环境下安装redis和phpredis的扩展 1.首先配置php: 需要在windows的集成环境中找到php的扩展文件夹,ext,然后在网上寻找自己的php对应的.dll文件 比如说的我的phpinfo里面显示是Arti..:x86,所以需要选择X86,这个跟系统无关,我的系统还是64位的呢! 然后我的集成环境是ts而不是nts这个都可以在phpinfo文件中找到! 下载文件php_igbinary.dll,php_redis.dll 然后修改配置文件php.ini(php文件