简体   繁体   English

安装Python模块错误

[英]Installing Python Module Error

I'm a using Windows 7, Python 2.6. 我正在使用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= 我已经从http://code.google.com/p/pylevenshtein/downloads/detail?name=python-Levenshtein-0.10.1.tar.bz2&can=2&q=下载了Levenshtein扩展程序

I've set up the environment variables to C:\\PYTHON26;C:\\PYTHON26\\DLLs;C:\\PYTHON26\\LIB;C:\\PYTHON26\\LIB\\LIB-TK 我已经将环境变量设置为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: 当我运行python install setup.py实际安装它时,我得到:

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 Levenshtein并得到ImportError: No module named Levenshtein

import StringMatcher yields: 导入StringMatcher产生:

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. 似乎您的环境没有指向c编译器的路径。 Levenshtein library is written in C and should be compiled using ac compiler. Levenshtein库是用C编写的,应使用ac编译器进行编译。

I had the same problem, but resolved as described below. 我有同样的问题,但如下所述已解决。

Firstly, you should have Microsoft Visual Studio (for c compiler). 首先,您应该具有Microsoft Visual Studio(用于c编译器)。 I did never try other c compilers for windows. 我从未尝试过其他Windows的C编译器。

Then do the below steps: 然后执行以下步骤:

  1. set path=C:\\Python26\\Scripts;C:\\Python26;%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). 只需运行:C:\\ Program Files(x86)\\ Microsoft Visual Studio 9.0 \\ VC \\ bin \\ vcvars32.bat(路径根据您的Visual Studio安装区域而异)。 This is to set paths to MS VS. 这是为MS VS设置路径。
    1. set VS90COMNTOOLS=C:\\Program Files (x86)\\Microsoft Visual Studio 9.0\\Common7\\Tools\\ (put your installed path to visual studio) 设置VS90COMNTOOLS = C:\\ Program Files(x86)\\ Microsoft Visual Studio 9.0 \\ Common7 \\ Tools \\(将安装路径放入Visual Studio)
    2. python setup.py build (optionally you can use --compiler msvc, ie python setup.py build --compiler msvc) python setup.py build(可选地,您可以使用--compiler msvc,即python setup.py build --compiler msvc)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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