2015-07-03 48 views
10

我正在尝试使用pip工具安装scikits.audiolab。 Pip似乎在scikits.audiolab源目录中运行命令python setup.py egg_info。当这样的时候,我得到这个错误:使用python setup.py时安装scikits.audiolab时出错egg_info

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脚本,这种进口发生早期(在片段的下方底部):

#! /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 

奇怪的是,如果我只是通过python setup.py运行setup.py脚本的上述片段,我没有得到导入错误。 egg_info命令行参数如何影响setup.py的运行方式,以及为什么突然使python无法从numpy.distutils.core导入?

+1

似乎不太可能,它是egg_info命令,而是点子正在改变以某种方式对环境.. 。点子使用正确的环境吗?你可以用pip -V –

+0

来检查,或许这与你的问题有关:https://github.com/scipy/scipy/blob/v0.13.0b1/setup.py#L203 – denfromufa

+0

如果numpy是这样安装的,那么它可能会工作:pip安装numpy - 用户 – denfromufa

回答

2

scikits.audiolabsetup.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,则可以确保这会导致您分享的导入错误失败。

我怀疑你的失败的安装尝试和你的成功安装之间,你用pip install numpy手动安装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, 
    ) 
相关问题