Error installing scikits.audiolab when using python setup.py egg_info
Asked Answered
C

1

9

I am trying to install scikits.audiolab with using the pip tool. Pip appears to run the command python setup.py egg_info from within the scikits.audiolab source directory. When it does so, I get this error:

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

The issue is clearly that it can't import numpy.distutils.core. Looking at the setup.py script, this import happens early on (at the bottom of the snippet below):

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

The odd part is that if I just run the above snippet of the setup.py script via python setup.py, I don't get the import error. How does the egg_info command line argument affect the way setup.py runs and why does it suddenly make python unable to import from numpy.distutils.core?

Colene answered 3/7, 2015 at 18:25 Comment(8)
Seems unlikely that it is the egg_info command, but rather that pip is changing the environment in some way... Is pip using the right environment? You can check that with pip -VShavonneshaw
perhaps this is related to your problem: github.com/scipy/scipy/blob/v0.13.0b1/setup.py#L203Hindermost
if numpy is installed like this, then it may work: pip install numpy --userHindermost
Thanks for the help. After inspecting the pip script, pip itself was using the wrong python version, so previously installed modules were not available in pip's environment. Changing the top line of pip to #!/usr/bin/env python fixed the issue.Colene
@Colene Was my comment helpful in debugging this and so worth writing up as an answer?Shavonneshaw
pip -V didn't actually reveal anything I didn't know frankly. It returned the correct site-packages location I expected. It wasn't until I looked at the code for the pip script itself I saw it was using the wrong python version all together.Colene
so you've successfully gotten audiolab installed?Townsley
Yes already installed itColene
A
3

There's a problem in scikits.audiolab's setup.py file. Take a look at 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

The very first thing it does is import from numpy. If numpy is not installed, this is guaranteed to fail with the import error you shared.

I suspect that between your failed installation attempt and your successful installation, you installed numpy manually with pip install numpy. It's unlikely that egg_info had anything to do with it.

Here's a demonstration of how to work around this problem, taken from the scipy project's setup.py:

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

    metadata = dict(
        ...
        setup_requires = build_requires,
        install_requires = build_requires,
    )
Adkisson answered 16/7, 2015 at 0:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.