2013-05-19 10 views
6

Ich bin auf Python 2.7 und ich versuche, die NLTK Teil der Rede Tagger zu verwenden, die diesen Fehler erzeugt, weil ich nicht numpy installiert haben:kann nicht installiert numpy mit setup.py

> Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/Library/Python/2.7/site-packages/nltk/tag/__init__.py", line 99, in pos_tag 
    tagger = load(_POS_TAGGER) 
    File "/Library/Python/2.7/site-packages/nltk/data.py", line 605, in load 
    resource_val = pickle.load(_open(resource_url)) 
ImportError: No module named numpy.core.multiarray 

So lade ich numpy 1.7.0 von here, hat eine cD in meinem Download-Ordner und python haben setup.py installieren und habe diesen Fehler:

Running from numpy source directory. 
non-existing path in 'numpy/distutils': 'site.cfg' 
F2PY Version 2 
blas_opt_info: 
    FOUND: 
    extra_link_args = ['-Wl,-framework', '-Wl,Accelerate'] 
    define_macros = [('NO_ATLAS_INFO', 3)] 
    extra_compile_args = ['-msse3', '-I/System/Library/Frameworks/vecLib.framework/Headers'] 

lapack_opt_info: 
    FOUND: 
    extra_link_args = ['-Wl,-framework', '-Wl,Accelerate'] 
    define_macros = [('NO_ATLAS_INFO', 3)] 
    extra_compile_args = ['-msse3'] 

running install 
running build 
running config_cc 
unifing config_cc, config, build_clib, build_ext, build commands --compiler options 
running config_fc 
unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options 
running build_src 
build_src 
building py_modules sources 
creating build 
creating build/src.macosx-10.6-intel-2.7 
creating build/src.macosx-10.6-intel-2.7/numpy 
creating build/src.macosx-10.6-intel-2.7/numpy/distutils 
building library "npymath" sources 
customize Gnu95FCompiler 
Could not locate executable gfortran 
Could not locate executable f95 
customize NAGFCompiler 
customize AbsoftFCompiler 
Could not locate executable f90 
Could not locate executable f77 
customize IBMFCompiler 
Could not locate executable xlf90 
Could not locate executable xlf 
customize IntelFCompiler 
Could not locate executable ifort 
Could not locate executable ifc 
customize GnuFCompiler 
Could not locate executable g77 
customize G95FCompiler 
Could not locate executable g95 
customize PGroupFCompiler 
Could not locate executable pgfortran 
don't know how to compile Fortran code on platform 'posix' 
C compiler: gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -arch i386 -arch x86_64 -g -O2 -DNDEBUG -g -O3 

compile options: '-Inumpy/core/src/private -Inumpy/core/src -Inumpy/core -Inumpy/core/src/npymath -Inumpy/core/src/multiarray -Inumpy/core/src/umath -Inumpy/core/src/npysort -Inumpy/core/include -I/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c' 
gcc-4.2: _configtest.c 
sh: gcc-4.2: command not found 
sh: gcc-4.2: command not found 
failure. 
removing: _configtest.c _configtest.o 
Traceback (most recent call last): 
    File "setup.py", line 214, in <module> 
    setup_package() 
    File "setup.py", line 207, in setup_package 
    configuration=configuration) 
    File "/Users/mikaschiller/Downloads/numpy-1.7.0/numpy/distutils/core.py", line 186, in setup 
    return old_setup(**new_attr) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 152, in setup 
    dist.run_commands() 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 953, in run_commands 
    self.run_command(cmd) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command 
    cmd_obj.run() 
    File "/Users/mikaschiller/Downloads/numpy-1.7.0/numpy/distutils/command/install.py", line 55, in run 
    r = old_install.run(self) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/install.py", line 563, in run 
    self.run_command('build') 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command 
    self.distribution.run_command(command) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command 
    cmd_obj.run() 
    File "/Users/mikaschiller/Downloads/numpy-1.7.0/numpy/distutils/command/build.py", line 37, in run 
    old_build.run(self) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/command/build.py", line 127, in run 
    self.run_command(cmd_name) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/cmd.py", line 326, in run_command 
    self.distribution.run_command(command) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 972, in run_command 
    cmd_obj.run() 
    File "/Users/mikaschiller/Downloads/numpy-1.7.0/numpy/distutils/command/build_src.py", line 152, in run 
    self.build_sources() 
    File "/Users/mikaschiller/Downloads/numpy-1.7.0/numpy/distutils/command/build_src.py", line 163, in build_sources 
    self.build_library_sources(*libname_info) 
    File "/Users/mikaschiller/Downloads/numpy-1.7.0/numpy/distutils/command/build_src.py", line 298, in build_library_sources 
    sources = self.generate_sources(sources, (lib_name, build_info)) 
    File "/Users/mikaschiller/Downloads/numpy-1.7.0/numpy/distutils/command/build_src.py", line 385, in generate_sources 
    source = func(extension, build_dir) 
    File "numpy/core/setup.py", line 648, in get_mathlib_info 
    raise RuntimeError("Broken toolchain: cannot link a simple C program") 
RuntimeError: Broken toolchain: cannot link a simple C program 

ich pip installieren dann versuchte es mit sudo zu installieren -U numpy und bekam den gleichen Fehler "kann ein einfaches C-Programm nicht verbinden". Ich kann nicht herausfinden, was hier vor sich geht. Ist die numpy Version mit Python 2.7 oder NLTK inkompatibel?

Antwort

4

Das Modul hängt von einer funktionierenden C-Kette ab. Es hängt von Ihrem System ab, wie Sie es installieren, Google wird in diesem Fall helfen.

Sie können es sehen für gcc suchen:

sh: gcc-4.2: command not found 

Auf Debian-basierten Linux würden Sie das und die Python-Header mit (bearbeitet pro Kommentar) installieren:

sudo apt-get install build-essential python-dev 
+1

Vergessen Sie nicht, dass Sie auch das Paket 'python-dev' auf diesen Systemen benötigen. – Cairnarvon

+0

Ich bin auf Mac Lion 10.7.5 mit Xcode 4.6 und installiere nur Kommandozeilen-Tools. Ich habe gcc -v in der Befehlszeile, um zu sehen, ob gcc installiert ist und es zurückgegeben (gekürzt): Mit eingebauten Spezifikationen. Ziel: i686-apple-darwin11 .... Thread-Modell: Posix GCC-Version 4.2.1 (Basierend auf Apple Inc. Build 5658) (LLVM Build 2336.11.00). Also gcc ist anscheinend installiert. Ich habe versucht, setup.py erneut auf numpy installieren und bekam den gleichen "Broken toolchain ..." Fehler. Ist das nicht die richtige Version von gcc für Löwe? –

+0

versuchen Sie dies von http: //www.scipy.org/Installation_SciPy/Mac_OS_X # head-9ec15aabd402675e5139a8c9c727e6a23513d56a 'exportieren CC = gcc; exportieren CXX = g ++; Export FFLAGS = ff2c' – globin

0

Vielleicht nicht, was Sie brauchen, aber wenn Sie Probleme mit der Installation von numpy haben, empfehle ich "Pyzo". Es ist eine Python-Distribution, die mit einem sehr interessanten Satz von Paketen einhergeht, unter denen sich numpy befindet. www.pyzo.org

1

Sie müssen gcc installieren.

Auf CentOS:

sudo yum install gcc 

Versuchen numpy neu zu installieren, wenn Sie sehen den folgenden Fehler:

Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-root/numpy 

Run:

sudo yum install python-devel 
2

Ich lief auf den gleichen Fehler und behob es durch Aktualisierung von Pip.

pip install --upgrade pip 

Hoffe, dass es hilft.

+0

Sie müssen wayyy up sein! – wolfgang