我已经从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__'
当我在Google中搜索时,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
不幸的是,这并没有为我解决错误。
希望有人能阐明一些想法吗?
非常感谢您的帮助!
答案 0 :(得分:1)
感谢@DavidW。这是我所做的,并且可以解决问题:
首先,由于我使用的是Collaboratory,因此我刚刚重新启动了会话以卸载pandana。
然后我升级了Cython:
import sys
!{sys.executable} -m pip install --upgrade cython
# Output:
Collecting cython
Downloading https://files.pythonhosted.org/packages/45/f2/a7101b3457561e57f5abcd6f5ac13190054fecd7370f58f36fe2d6574742/Cython-0.29.13-cp36-cp36m-manylinux1_x86_64.whl (2.1MB)
|████████████████████████████████| 2.1MB 1.9MB/s eta 0:00:01
Installing collected packages: cython
Successfully installed cython-0.29.13
只有那时,我安装了pandana:
!{sys.executable} -m pip install pandana
现在工作正常。
所以@ead到this github-issue的链接似乎很有意义。 cython实现的程序包是从不正确的Cython版本开始构建的。必须先卸载,然后再升级Cython,然后才能安装pandana。