Python AttributeError:type object';pandana.cyaccess.cyaccess';没有属性'__减少cython';

Python AttributeError:type object';pandana.cyaccess.cyaccess';没有属性'__减少cython';,python,python-3.x,numpy,cython,conda,Python,Python 3.x,Numpy,Cython,Conda,我已经从git安装了pandana: !{sys.executable}-m pip安装git+git://github.com/udst/pandana.git 在我的jupyterlab上: /home/jupyterlab/conda/envs/python/lib/python3.6/site-packages(来自fiona->geopandas>=0.2.1->osmnet>=0.1.2->pandana)(7.0) 我正在运行以下代码: import pandana, time,

我已经从git安装了pandana:

!{sys.executable}-m pip安装git+git://github.com/udst/pandana.git

在我的jupyterlab上:

/home/jupyterlab/conda/envs/python/lib/python3.6/site-packages(来自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__'
我还尝试使用conda进行下载,这似乎对某些人也有用:

# Install a conda package in the current Jupyter kernel
import sys
!conda install --yes --prefix {sys.prefix} pandana
不幸的是,这并没有为我解决这个错误

希望有人能给我们一些启示


非常感谢你的帮助

谢谢@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与的链接似乎是有意义的。cython实现的包最初是用不正确的cython版本构建的。必须先卸载,然后升级Cython,然后才安装pandana

我从来都不知道如何帮助解决这类问题:(在Linux上使用Python3.7)我可以编译和导入Pandana,因此它显然没有完全崩溃;我们认为问题可能在于文件是用过时的Cython版本编译的,现在应该修复(但它可能总是一个难以诊断的持续错误);这个错误消息显然让很多人感到沮丧,但我不太清楚您实际是如何诊断它的。我想知道您能做的最好的事情是否是安装一个新的Conda环境,其中只包含Pandana所需的最低限度的软件包,并准确记录这些软件包是什么以及您运行了哪些命令来安装它们。然后至少有人可以尝试构建完全相同的环境
!{sys.executable} -m pip install pandana