2017-08-24 41 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編譯器,然後是一堆額外的庫,這些庫又可能有自己的需求。