AttributeError:类型对象'pandana.cyaccess.cyaccess访问'没有属性'\u reduce\u cython\u'

2024-06-25 22:33:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我从git安装了pandana:

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

在我的实验室里:

/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波音的教程:andana可访问性演示-完整.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

不幸的是,这并没有解决我的错误。你知道吗

希望有人能给我们一些启示?你知道吗

非常感谢你的帮助!你知道吗


Tags: ofinfromimportnumpyforlibpackages
1条回答
网友
1楼 · 发布于 2024-06-25 22:33:06

谢谢@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。你知道吗

相关问题 更多 >