2017-08-24 29 views
0

我知道这是一个严重记录的问题,但没有发布的解决方案已解决我的问题。试图在setup.py中安装numpy

这是我的代码

#!/usr/bin/env python 

import os 
from setuptools import setup, Extension 
from setuptools.command.build_ext import build_ext as _build_ext 

class build_ext(_build_ext): 
    def finalize_options(self): 
    _build_ext.finalize_options(self) 
    # Prevent numpy from thinking it is still in its setup process: 
    __builtins__.__NUMPY_SETUP__ = False 
    import numpy 
    self.include_dirs.append(numpy.get_include()) 

setup(
    name='MLM', 
    version='0.2dev', 
    setup_requires=['numpy'], 
    cmdclass={'build_ext': build_ext}, 
    install_requires=[ 
    'nltk', 
    'numpy' 
    ], 
    license='MIT', 
    long_description=open('../README.md').read, 

然而,当我运行python setup.py install我得到:

File "D:\python\lib\site-packages\setuptools\command\easy_install.py", line 1106, in run_setup 
    raise DistutilsError("Setup script exited with %s" % (v.args[0],)) 
distutils.errors.DistutilsError: Setup script exited with error: Microsoft Visual C++ 9.0 is required. Get it from http://aka.ms/vcpython27 
+0

您是否按照说明安装了MSVC++ 9? – lxop

+0

@lxop这是可以添加到setup.py文件的东西吗? – Kat

回答

0

您收到错误消息是相当清楚的:

distutils.errors.DistutilsError: Setup script exited with error: Microsoft Visual C++ 9.0 is required. Get it from http://aka.ms/vcpython27

我认为你还没有尝试过,因为我怀疑如果你做了它,要么为你工作,要么你更可能会问一个不同的问题。

但是,按照错误消息中提供的步骤可能不是这一个特定情况下的最佳选择。相反,我会建议下载并安装预编译版本的numpy for windows,也许这里正式提供的版本:https://docs.scipy.org/doc/numpy-1.10.1/user/install.html#windows

在这种情况下,我怀疑预编译版本比尝试构建您的因为numpy不仅仅需要Windows的相应C++编译器,它还需要一个兼容的FORTRAN-77编译器,然后是一堆额外的库,这些库又可能有自己的需求。