如何在Windows

时间:2017-12-12 18:46:40

标签: windows pip install anaconda scikits

我目前正在尝试在Windows 10上为Python 3.5.4安装scikits.audiolab 0.11.0,它需要来自http://www.mega-nerd.com/libsndfile/的libsndfile。我已将其安装到我的conda虚拟环境中,以便文件路径如下所示:

C:\Users\MXJ719\AppData\Local\Continuum\anaconda3\envs\wavenet\libs\libsndfile

然后我在

中编辑site.cfg文件
C:\Users\MXJ719\AppData\Local\Continuum\anaconda3\envs\wavenet\Lib\site-packages\numpy\distutils

阅读:

[sndfile]
library_dirs = C:\Users\MXJ719\AppData\Local\Continuum\anaconda3\envs\wavenet\libs\libsndfile;C:\Users\MXJ719\AppData\Local\Continuum\anaconda3\envs\wavenet\libs\libsndfile\lib
include_dirs = C:\Users\MXJ719\AppData\Local\Continuum\anaconda3\envs\wavenet\libs\libsndfile;C:\Users\MXJ719\AppData\Local\Continuum\anaconda3\envs\wavenet\libs\libsndfile\include
sndfile_libs = sndfile-1

然后我在anaconda提示符下激活我的wavenet环境并输入:

pip install scikits.audiolab==0.11.0

,它给出了以下错误和Traceback:

(wavenet) C:\Windows>pip install scikits.audiolab==0.11.0
Collecting scikits.audiolab==0.11.0
    Using cached scikits.audiolab-0.11.0.tar.gz
        Complete output from command python setup.py egg_info:
        SndfileInfo:
            libraries sndfile not found in C:\Users\MXJ719\AppData\Local\Continuum\anaconda3\envs\wavenet\libs\libsndfile
            libraries sndfile not found in C:\Users\MXJ719\AppData\Local\Continuum\anaconda3\envs\wavenet\libs\libsndfile\lib
        Traceback (most recent call last):
            File "scikits\audiolab\pysndfile\setup.py", line 20, in configuration
              sf_config = sf_info.get_info(2)
            File "C:\Users\MXJ719\AppData\Local\Continuum\anaconda3\envs\wavenet\lib\site-packages\numpy\distutils\system_info.py", line 578, in get_info
              raise self.notfounderror(self.notfounderror.__doc__)
        numpy.distutils.system_info.NotFoundError: Some third-party program or library is not found.

        During handling of the above exception, another exception occurred:

        Traceback (most recent call last):
          File "<string>", line 1, in <module>
          File "C:\Users\MXJ719\AppData\Local\Temp\pip-build-bet3e29j\scikits.audiolab\setup.py", line 85, in <module>
            classifiers=CLASSIFIERS)
          File "C:\Users\MXJ719\AppData\Local\Continuum\anaconda3\envs\wavenet\lib\site-packages\numpy\distutils\core.py", line 135, in setup
            config = configuration()
          File "C:\Users\MXJ719\AppData\Local\Temp\pip-build-bet3e29j\scikits.audiolab\setup.py", line 71, in configuration
            config.add_subpackage(DISTNAME)
          File "C:\Users\MXJ719\AppData\Local\Continuum\anaconda3\envs\wavenet\lib\site-packages\numpy\distutils\misc_util.py", line 1029, in add_subpackage
            caller_level = 2)
          File "C:\Users\MXJ719\AppData\Local\Continuum\anaconda3\envs\wavenet\lib\site-packages\numpy\distutils\misc_util.py", line 998, in get_subpackage
            caller_level = caller_level + 1)
          File "C:\Users\MXJ719\AppData\Local\Continuum\anaconda3\envs\wavenet\lib\site-packages\numpy\distutils\misc_util.py", line 935, in _get_configuration_from_setup_py
            config = setup_module.configuration(*args)
          File "scikits\audiolab\setup.py", line 10, in configuration
            confgr.add_subpackage('pysndfile')
          File "C:\Users\MXJ719\AppData\Local\Continuum\anaconda3\envs\wavenet\lib\site-packages\numpy\distutils\misc_util.py", line 1029, in add_subpackage
            caller_level = 2)
          File "C:\Users\MXJ719\AppData\Local\Continuum\anaconda3\envs\wavenet\lib\site-packages\numpy\distutils\misc_util.py", line 998, in get_subpackage
            caller_level = caller_level + 1)
          File "C:\Users\MXJ719\AppData\Local\Continuum\anaconda3\envs\wavenet\lib\site-packages\numpy\distutils\misc_util.py", line 935, in _get_configuration_from_setup_py
            config = setup_module.configuration(*args)
          File "scikits\audiolab\pysndfile\setup.py", line 25, in configuration
            site.cfg file, in section [sndfile].""")
numpy.distutils.system_info.NotFoundError: sndfile (http://www.mega-nerd.com/libsndfile/) library not found.
Directories to search for the libraries can be specified in the
site.cfg file, in section [sndfile].

----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in 
C:\Users\MXJ719\AppData\Local\Temp\pip-build-bet3e29j\scikits.audiolab\

我想知道为什么安装程序似乎没有&#34;看到&#34;我在site.cfg文件中给出的libsndfile目录,并指示如何修复此问题以安装scikits.audiolab版本0.11.0

2 个答案:

答案 0 :(得分:0)

从sndfile库文件名中删除“ -1”。

在您的情况下:

  1. libsndfile-1.lib重命名为libsndfile.lib
  2. libsndfile-1.def重命名为libsndfile.def

这些文件位于C:\Users\MXJ719\AppData\Local\Continuum\anaconda3\envs\wavenet\libs\libsndfile\lib中。

我在C:\Program Files\Mega-Nerd\libsndfile\中安装sndfile时遇到了同样的问题。

我的C:\Users\[userNameHere]\site.cfg文件具有以下内容:

[sndfile]
library_dirs = C:\Program Files\Mega-Nerd\libsndfile\lib\
include_dirs = C:\Program Files\Mega-Nerd\libsndfile\include\

(定义{{​​1}}对我没有明显影响,因此我将其省略。)

希望这对您来说足够了。解决此问题后,我遇到了其他问题,但我将尝试在https://github.com/cournape/audiolab/issues/7

寻求帮助。

答案 1 :(得分:0)

如果您的问题只是sndfile,则只需对site.cfg进行设置配置

site.cfg.example中的表单如下:

[sndfile]
include_dirs = c:\local\include
library_dirs = c:\local\lib
sndfile_libs = sndfile-1

使用2个可选条件进行更改:

******第一种方法******

基于site.cfg中设置的变量,重命名libsndfile库(* .lib),

[sndfile]
    include_dirs = C:\Program Files\Mega-Nerd\libsndfile\include
    library_dirs = C:\Program Files\Mega-Nerd\libsndfile\lib

    #and you must really give an attention to the setting code below, if you put the setting like the original, setting like this script below

    sndfile_libs = sndfile-1

    #so all your file must in folder include_dirs should be renamed to: sndfile-1.h, sndfile-1.hh (in include folder) 
    #and renamed the lib file in library_dirs to: sndfile-1.lib and sndfile-1.lib

此后,必须确保该库位于您的PYTHONPATH中,如果您没有设置PYTHONPATH,请执行以下操作:

系统属性>>环境变量>>系统变量>>>新建

在新系统变量>>变量名称中输入PYTHONPATH

将include,lib和bin libsndfile路径dir输入到“变量值”,例如:

'YOUR PYTHON FOLDER that have python.exe'; 'YOUR PYTHON SCRIPT FOLDER';C:\Program Files\Mega-Nerd\libsndfile\lib;C:\Program Files\Mega-Nerd\libsndfile\include;C:\Program Files\Mega-Nerd\libsndfile\bin

然后按OK

之后,您应该在路径中输入PYTHONPATH

只需编辑您的Path variabel名称,并使用%PYTHONPATH%添加新行

如果您已经设置/设置了PYTHONPATH环境,只需添加编辑并添加新行即可

C:\Program Files\Mega-Nerd\libsndfile\lib;C:\Program Files\Mega-Nerd\libsndfile\include;C:\Program Files\Mega-Nerd\libsndfile\bin

或使用:

*****第二种方法*****,

将文件site.cfg设置为您的python目录

[sndfile]
include_dirs = c:\users\admin\appdata\local\programs\python\python37\include
library_dirs = c:\users\admin\appdata\local\programs\python\python37\libs
sndfile_libs = 'change this base with your libsndfile's library name 
#so, you don't have to make many step

使用此设置,我的python可以识别libsndfile的位置

在我的情况下,另一个模块也需要libsndfile库,该库以不同的名称搜索该库,因此在我的python文件夹中,我将libsndfile复制为多个名称,这取决于模块如何搜索该库。