简体   繁体   中英

Installing Python Module Error

I'm a using Windows 7, Python 2.6. I've downloaded the Levenshtein extension from http://code.google.com/p/pylevenshtein/downloads/detail?name=python-Levenshtein-0.10.1.tar.bz2&can=2&q=

I've set up the environment variables to C:\\PYTHON26;C:\\PYTHON26\\DLLs;C:\\PYTHON26\\LIB;C:\\PYTHON26\\LIB\\LIB-TK

When I run the python install setup.py to actually install it, I get:

running install
running build
running build_ext
building 'Levenshtein' extension
error: None

Then I try to import Levenshtein and I get the ImportError: No module named Levenshtein

import StringMatcher yields:

Traceback (most recent call last):
File "(stdin)", line 1, in (module)
File "stringMatcher.py", line 1, in (module)
from Levenshtein imoprt *
ImportError: No module name Levenshtein

Am I missing something stupid? This seems to happen with every extra module that I try to install.

如果安装正确,则应通过将C:\\ Python26 \\ Lib \\ site-packages添加到python路径来工作

Seems to be that your environment did not have paths to the c compiler. Levenshtein library is written in C and should be compiled using ac compiler.

I had the same problem, but resolved as described below.

Firstly, you should have Microsoft Visual Studio (for c compiler). I did never try other c compilers for windows.

Then do the below steps:

  1. set path=C:\\Python26\\Scripts;C:\\Python26;%path%
  2. Just run: C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\VC\\bin\\vcvars32.bat (path varies according to your visual studio installed area). This is to set paths to MS VS.
    1. set VS90COMNTOOLS=C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\Common7\\Tools\\ (put your installed path to visual studio)
    2. python setup.py build (optionally you can use --compiler msvc, ie python setup.py build --compiler msvc)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM