![](/img/trans.png)
[英]AttributeError: type object 'sklearn.manifold._barnes_hut_tsne.array' has no attribute '__reduce_cython__'
[英]AttributeError: type object 'pandana.cyaccess.cyaccess' has no attribute '__reduce_cython__'
我已經從 git 安裝了熊貓:
.{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
不幸的是,這並沒有解決我的錯誤。
希望任何人都可以有所啟發?
非常感謝你的幫助!
謝謝@DavidW。 這是我所做的,它解決了問題:
首先,由於我使用的是 Collaboratory,我剛剛重新啟動了我的 session 以卸載 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 到這個 github-issue的鏈接是有道理的。 cython 實現的 package 一開始就使用不正確的 Cython 版本構建。 必須卸載,然后升級 Cython,然后才能安裝 Pandana。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.