版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/fancychuan/article/details/68946965
参考这篇文章:http://geoffboeing.com/2016/11/osmnx-python-street-networks/
geopandas安装方法:http://geoffboeing.com/2014/09/using-geopandas-windows/
安装方法:
1. 使用conda(anaconda自带的包管理器,强烈建议按照anaconda作为python开发环境)
conda install -c conda-forge osmnx
2. 使用pip
pip install osmnx
但是使用pip按照的话,需要手动装上依赖。具体看文章。思路就是那个包装不上就去寻找相应包的 whl 文件。
主把安装过程中会遇到的问题记录下:
错误一:缺乏 vcpython
VCInstallDir
distutils.errors.DistutilsPlatformError: Microsoft Visual C++ 9.0 is required. Get it from http://aka.ms/vcpython27
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in c:\users\temp\appdata\local\temp\pip-build-dannsw\pyproj\
按照提示,到 http://aka.ms/vcpython27 下载装上即可
错误二: 版本匹配问题
Found existing installation: matplotlib 1.5.3
Uninstalling matplotlib-1.5.3:
Exception:
Traceback (most recent call last):
File "D:\Program Files (x86)\Anaconda2\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "D:\Program Files (x86)\Anaconda2\lib\site-packages\pip\commands\install.py", line 317, in run
prefix=options.prefix_path,
File "D:\Program Files (x86)\Anaconda2\lib\site-packages\pip\req\req_set.py", line 736, in install
requirement.uninstall(auto_confirm=True)
File "D:\Program Files (x86)\Anaconda2\lib\site-packages\pip\req\req_install.py", line 742, in uninstall
paths_to_remove.remove(auto_confirm)
File "D:\Program Files (x86)\Anaconda2\lib\site-packages\pip\req\req_uninstall.py", line 115, in remove
renames(path, new_path)
File "D:\Program Files (x86)\Anaconda2\lib\site-packages\pip\utils\__init__.py", line 267, in renames
shutil.move(old, new)
File "D:\Program Files (x86)\Anaconda2\lib\shutil.py", line 300, in move
rmtree(src)
File "D:\Program Files (x86)\Anaconda2\lib\shutil.py", line 252, in rmtree
onerror(os.remove, fullname, sys.exc_info())
File "D:\Program Files (x86)\Anaconda2\lib\shutil.py", line 250, in rmtree
os.remove(fullname)
WindowsError: [Error 5] : 'd:\\program files (x86)\\anaconda2\\lib\\site-packages\\matplotlib\\_path.pyd'
Collecting pandas>=0.19 (from osmnx)
Could not find a version that satisfies the requirement pandas>=0.19 (from osmnx) (from versions: )
No matching distribution found for pandas>=0.19 (from osmnx)
需要手动升级:
conda update matplotlib --no-update-dependencies
conda update pandas --no-update-dependencies
错误三:按照后 import 错误
OSError: could not find or load spatialindex_c.dll
这里的主要错误是Rtree这个包,参考这篇文章,很详细;http://www.cnblogs.com/yangzhang-home/p/5999812.html,还有一篇http://www.zhimengzhe.com/windows/136713.html
参考资料:
用conda管理python包:http://blog.sina.com.cn/s/blog_c3c116470102wlv5.html
错误四: fiona import 错误
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-3-0c9777b3c6b2> in <module>()
----> 1 boros = GeoDataFrame.from_file('nybb.shp')
/Users/danqing0703/anaconda/lib/python2.7/site-packages/geopandas/geodataframe.pyc in from_file(cls, filename, **kwargs)
159
160 """
--> 161 return geopandas.io.file.read_file(filename, **kwargs)
162
163 @classmethod
/Users/danqing0703/anaconda/lib/python2.7/site-packages/geopandas/io/file.pyc in read_file(filename, **kwargs)
9 opening the file.
10 """
---> 11 import fiona
12 bbox = kwargs.pop('bbox', None)
13 with fiona.open(filename, **kwargs) as f:
/Users/danqing0703/anaconda/lib/python2.7/site-packages/fiona/__init__.py in <module>()
70 from six import string_types
71
---> 72 from fiona.collection import Collection, BytesCollection, vsi_path
73 from fiona._drivers import driver_count, GDALEnv, supported_drivers
74 from fiona.odict import OrderedDict
/Users/danqing0703/anaconda/lib/python2.7/site-packages/fiona/collection.py in <module>()
5 import sys
6
----> 7 from fiona.ogrext import Iterator, ItemsIterator, KeysIterator
8 from fiona.ogrext import Session, WritingSession
9 from fiona.ogrext import (
我的原因是因为没有装 GDAL这个包。
参考文章:http://gis.stackexchange.com/questions/121157/how-to-fix-python-importerror-dll-load-failed-the-specified-module-could-not-b