3

好吧,我正在尝试安装 PyMSSQL-2.0.0b1,但无法实现,出现奇怪的错误...我尝试了一些在 Google 和 StackOverflow 上找到的解决方案,但仍然无法编译...

请问我错过了什么?

(所以我试过:

- to add --compiler=mingw32 after setup.py install build 
- to create a distutils.cfd file in Python27\lib\distutils\distutils.cfg with 
    [build]
    compiler=mingw32

仍然无法正常工作)

(我也在 Windows 7 上,我需要第三方库,必须坚持 32 位版本和 2.7)

这是一些有错误的日志:

C:\Users\MyUserName\Desktop\downloaded\python\pymssql-2.0.0b1-dev-20111019>setup.py install build
running install
running bdist_egg
running egg_info
writing pymssql.egg-info\PKG-INFO
writing top-level names to pymssql.egg-info\top_level.txt
writing dependency_links to pymssql.egg-info\dependency_links.txt
reading manifest file 'pymssql.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'pymssql.egg-info\SOURCES.txt'
installing library code to build\bdist.win32\egg
running install_lib
running build_ext
skipping '_mssql.c' Cython extension (up-to-date)
building '_mssql' extension
error: Unable to find vcvarsall.bat

C:\Users\MyUserName\Desktop\downloaded\python\pymssql-2.0.0b1-dev-20111019>setup.
py install build --compiler=mingw32
running install
running bdist_egg
running egg_info
writing pymssql.egg-info\PKG-INFO
writing top-level names to pymssql.egg-info\top_level.txt
writing dependency_links to pymssql.egg-info\dependency_links.txt
reading manifest file 'pymssql.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'pymssql.egg-info\SOURCES.txt'
installing library code to build\bdist.win32\egg
running install_lib
running build_ext
skipping '_mssql.c' Cython extension (up-to-date)
building '_mssql' extension
c:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Users\MyUserName\Desktop\laur
ent.CTV\python\pymssql-2.0.0b1-dev-20111019\win32\freetds\include -IC:\Python27\
include -IC:\Python27\PC -c _mssql.c -o build\temp.win32-2.7\Release\_mssql.o -D
MSDBLIB -Wl,-allow-multiple-definition -Wl,-subsystem,windows-mthreads -mwindows
 -Wl,--strip-all
cc1.exe: erreur: unrecognized command line option '-mno-cygwin'
error: command 'gcc' failed with exit status 1

C:\Users\MyUserName\Desktop\downloaded\python\pymssql-2.0.0b1-dev-20111019>python

Python 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)] on win
32
Type "help", "copyright", "credits" or "license" for more information.
>>> ^Z

C:\Users\MyUserName\Desktop\downloaded\python\pymssql-2.0.0b1-dev-20111019>gcc --version
gcc (GCC) 4.6.1
Copyright © 2011 Free Software Foundation, Inc.
Ce logiciel est libre; voir les sources pour les conditions de copie.  Il n'y a
PAS
GARANTIE; ni implicite pour le MARCHANDAGE ou pour un BUT PARTICULIER.

创建 disutils.cfg 后

C:\Users\MyUserName\Desktop\downloaded\python\pymssql-2.0.0b1-dev-20111019>setup.py install build
running install
running bdist_egg
running egg_info
writing pymssql.egg-info\PKG-INFO
writing top-level names to pymssql.egg-info\top_level.txt
writing dependency_links to pymssql.egg-info\dependency_links.txt
reading manifest file 'pymssql.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
writing manifest file 'pymssql.egg-info\SOURCES.txt'
installing library code to build\bdist.win32\egg
running install_lib
running build_ext
skipping '_mssql.c' Cython extension (up-to-date)
building '_mssql' extension
c:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Users\MyUserName\Desktop\laur
ent.CTV\python\pymssql-2.0.0b1-dev-20111019\win32\freetds\include -IC:\Python27\
include -IC:\Python27\PC -c _mssql.c -o build\temp.win32-2.7\Release\_mssql.o -D
MSDBLIB -Wl,-allow-multiple-definition -Wl,-subsystem,windows-mthreads -mwindows
 -Wl,--strip-all
cc1.exe: erreur: unrecognized command line option '-mno-cygwin'
error: command 'gcc' failed with exit status 1

C:\Users\MyUserName\Desktop\downloaded\python\pymssql-2.0.0b1-dev-20111019>type c:\Python27\lib\distutils\distutils.cfg
[build]
compiler=mingw32

编辑:看起来像一个与http://bugs.python.org/issue12641和“-mno-cygwin”部分相关的未解决问题(顺便说一句,如果我的理解没问题)

4

5 回答 5

4

当您为 python 2.7 安装软件包时,它会搜索 Visual Studio 2008。我所要做的就是在调用 setup.py 之前设置 VS90COMNTOOLS 变量

如果您安装了 Visual Studio 2010,请执行

设置 VS90COMNTOOLS=%VS100COMNTOOLS%

或安装了 Visual Studio 2012

设置 VS90COMNTOOLS=%VS110COMNTOOLS%

于 2013-02-22T17:06:27.340 回答
0

尝试使用带有GCC 4.5.2的 MinGW 版本。

此版本支持该-mno-cygwin选项并且应该正确构建。

使用这个版本,我成功地在 Windows 7 64 位和 Python 2.7 32 位上构建了 PyMSSQL-2.0.0b1 。

我没有修改源压缩包。我刚刚在源目录中运行了以下命令:python setup.py build --compiler=mingw32. 我C:\MinGW\bin在我的路径中。

注意:我缺少 Cython,所以我下载了最新版本并使用 MinGW 构建它。我通过运行来做到这一点python setup.py build --compiler=mingw32。我唯一缺少的其他依赖项是 iconv 库,我使用这些方向在 MinGW 中构建了它。

于 2011-11-08T16:49:05.703 回答
0

您是否已经尝试使用 Visual Studio 附带的编译器而不是 MingW32 进行编译?(文件“vcvarsall.bat”初始化VS的环境)

Visual Studio 的 Express 版本是免费的)

于 2011-11-07T21:21:30.790 回答
0

你安装了 32 位还是 64 位版本的 python?请尝试安装 32 位版本。

于 2011-11-04T13:14:10.257 回答
-1

我认为你有错误的版本。

于 2011-11-09T22:21:01.607 回答