我已经从git安装了pandana:
!{sys.executable} -m pip install git+git://github.com/udst/pandana.git
在我的jupyterlab上:
/home/jupyterlab/conda/envs/python/lib/python3.6/site-packages (from fiona->geopandas>=0.2.1->osmnet>=0.1.2->pandana) (7.0)
我正在运行以下代码:
import pandana, time, os, pandas as pd, numpy as np
from pandana.loaders import osm
# define your selected amenities and bounding box
# configure search at a max distance of 1 km for up to the 10 nearest points-of-interest
amenities = ['restaurant', 'bar', 'food']
distance = 1000
num_pois = 10
num_categories = len(amenities) + 1 #one for each amenity, plus one extra for all of them combined
# bounding box as a list of llcrnrlat, llcrnrlng, urcrnrlat, urcrnrlng
# Bounding box for a Edinburgh, Scotland
west, south, east, north = (-3.449533, 55.818792, -3.074951, 56.004084)
bbox = [west, south, east, north] #lat-long bounding box for Edinburgh, Scotland
我遵循Geoff Boeing的教程:andana-accessibility-demo-full.ipynb
运行代码时,出现以下错误:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-183-27bb5991aaa3> in <module>
----> 1 import pandana, time, os, pandas as pd, numpy as np
2 from pandana.loaders import osm
3
4 # define your selected amenities and bounding box
5 # configure search at a max distance of 1 km for up to the 10 nearest points-of-interest
~/conda/envs/python/lib/python3.6/site-packages/pandana/__init__.py in <module>
----> 1 from .network import Network
2
3 version = __version__ = '0.4.4'
~/conda/envs/python/lib/python3.6/site-packages/pandana/network.py in <module>
9 from sklearn.neighbors import KDTree
10
---> 11 from .cyaccess import cyaccess
12 from .loaders import pandash5 as ph5
13 import warnings
src/cyaccess.pyx in init pandana.cyaccess()
AttributeError: type object 'pandana.cyaccess.cyaccess' has no attribute '__reduce_cython__'
当我在谷歌搜索时,reduce_cython
错误出现过几次,但我还没有找到解决问题的方法。到目前为止,我已经尝试过更新cython和numpy,这两个版本在面对相关问题时似乎对其他人有效:
!{sys.executable} -m pip install --upgrade cython
# Output: Requirement already up-to-date: cython in /home/jupyterlab/conda/envs/python/lib/python3.6/site-packages (0.29.13)
!{sys.executable} -m pip install --upgrade numpy
# Output: Requirement already up-to-date: numpy in /home/jupyterlab/conda/envs/python/lib/python3.6/site-packages (1.17.2)
我还尝试使用conda进行下载,这似乎对某些人也有用:
# Install a conda package in the current Jupyter kernel
import sys
!conda install --yes --prefix {sys.prefix} pandana
不幸的是,这并没有为我解决这个错误
希望有人能给我们一些启示
非常感谢你的帮助
谢谢@DavidW。下面是我所做的,它解决了问题:
首先,因为我使用的是Collaboratory,所以我刚刚重新启动了pandana卸载的会话
然后我升级了Cython:
直到那时,我才安装了pandana:
现在一切正常
因此,@ead与this github-issue的链接似乎有意义。cython实现的包最初是用不正确的cython版本构建的。必须先卸载,然后升级Cython,然后才安装pandana
相关问题 更多 >
编程相关推荐