Подтвердить что ты не робот

Ошибка при установке scikits.audiolab при использовании python setup.py egg_info

Я пытаюсь установить scikits.audiolab с помощью инструмента pip. Кажется, что Pip запускает команду python setup.py egg_info из исходного каталога scikits.audiolab. Когда это произойдет, я получаю эту ошибку:

Andrews-MacBook-Pro-2:scikits.audiolab-0.11.0 andrewhannigan$ pip install scikits.audiolab
Collecting scikits.audiolab
  Using cached scikits.audiolab-0.11.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "/private/var/folders/xb/qwlsm44s1wxfr82kytrgjtl80000gn/T/pip-build-vSZaU8/scikits.audiolab/setup.py", line 32, in <module>
        from numpy.distutils.core import setup
    ImportError: No module named numpy.distutils.core

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/xb/qwlsm44s1wxfr82kytrgjtl80000gn/T/pip-build-vSZaU8/scikits.audiolab

Проблема в том, что она не может импортировать numpy.distutils.core. Глядя на setup.py script, этот импорт происходит раньше (внизу фрагмента ниже):

#! /usr/bin/env python
# Last Change: Fri Mar 27 05:00 PM 2009 J

# Copyright (C) 2006-2007 Cournapeau David <[email protected]>
#
# This library is free software; you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 2.1 of the License, or (at your option) any
# later version.
#
# This library is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License along
# with this library; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

# TODO:
#   - check how to handle cmd line build options with distutils and use
#   it in the building process

from os.path import join
import os
import sys

# The following is more or less random copy/paste from numpy.distutils ...
import setuptools

from distutils.errors import DistutilsError
from numpy.distutils.core import setup

Нечетная часть заключается в том, что если я просто запустил вышеприведенный фрагмент setup.py script через python setup.py, я не получу ошибку импорта. Как аргумент командной строки egg_info влияет на способ запуска setup.py и почему он делает невозможным импорт python из numpy.distutils.core?

4b9b3361

Ответ 1

В файле scikits.audiolab setup.py возникает проблема. Взгляните на https://github.com/cournape/audiolab/blob/master/setup.py:

import os

# The following is more or less random copy/paste from numpy.distutils ...
import setuptools

from numpy.distutils.core import setup

Самое первое, что он делает - это импорт из numpy. Если numpy не установлен, это может привести к сбою с общей ошибкой импорта.

Я подозреваю, что между неудачной попыткой установки и успешной установкой вы установили numpy вручную с помощью pip install numpy. Маловероятно, чтобы egg_info имел к этому какое-то отношение.

Здесь демонстрируется, как обойти эту проблему, взятую из проекта scipy setup.py:

def setup_package():
    ...
    build_requires = []
    try:
        import numpy
    except:
        build_requires = ['numpy']

    metadata = dict(
        ...
        setup_requires = build_requires,
        install_requires = build_requires,
    )