名称错误:python 3中未定义名称“request”

2024-06-09 02:04:39 发布

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

我正在尝试从以下站点运行基本特征提取代码:
musicinformationretrieval
当我尝试运行以下代码行时:

kick_filepaths, snare_filepaths = stanford_mir.download_samples(collection="drum_samples_train")

它显示以下错误消息:

^{pr2}$

请帮我解决这个问题。在


Tags: 代码站点download错误traincollectionmirsamples
1条回答
网友
1楼 · 发布于 2024-06-09 02:04:39

似乎应该使用python2而不是3。在斯坦福的instruction里有一行:

  1. If you’re totally new, the simplest solution is to download and install Anaconda for Python 2 (2.7), not Python 3.

您还可以阅读它为什么不能在python3here上工作。在

升级版:

对于使用Python 3,可以在使用lib之前尝试添加代码:

import sys

if sys.version_info[0] >= 3:
    from urllib.request import urlretrieve
else:
    # Not Python 3 - today, it is most likely to be Python 2
    # But note that this might need an update when Python 4
    # might be around one day
    from urllib import urlretrieve

升级2: urlretrieve导入没有帮助)

相关问题 更多 >