35

Windows 64 ビット マシンで Python 2.7 用の lxml をビルドしようとしています。Python 2.7 バージョンの lxml 卵が見つかりませんでした。だから私はソースからコンパイルしています。このサイトの指示に従っています

http://lxml.de/build.html

静的リンクセクションの下。エラーが発生しています

C:\Documents and Settings\Administrator\Desktop\lxmlpackage\lxml-2.2.6\lxml-2.2.
6>python setup.py bdist_wininst --static
Building lxml version 2.2.6.
NOTE: Trying to build without Cython, pre-generated 'src/lxml/lxml.etree.c' need
s to be available.
ERROR: 'xslt-config' is not recognized as an internal or external command,
operable program or batch file.

** make sure the development packages of libxml2 and libxslt are installed **

Using build configuration of libxslt
Building against libxml2/libxslt in one of the following directories:
  ..\libxml2-2.7.6--win32--w2k--x64\lib
  ..\libxslt-1.1.26--win32--w2k--x64--0002\lib
  ..\zlib-1.2.4--win32--w2k--x64
  ..\iconv-1.9.1--win32--w2k--x64-0001\lib
running bdist_wininst
running build
running build_py
running build_ext
building 'lxml.etree' extension
error: Unable to find vcvarsall.bat

誰でもこれで私を助けることができますか? Microsoft Visual Studio があるようにパスを設定しようとしました..コマンドラインから vcvarsall.bat を実行できます..しかし、Python に問題があります

4

4 に答える 4

61

これにはVS 2008を使用していないに違いありません:)

次のコメントとともに、distutils にdef find_vcvarsall(version): function (これは vcvarsall.bat を探します) があります。

最初に、レジストリで VS 2008 の productdir を見つけようとします。それが失敗した場合、VS90COMNTOOLS 環境変数にフォールバックします。

VS 2008 を使用していない場合、レジストリ キーも適切な環境変数もないため、distutils は vcvarsall.bat ファイルを見つけることができません。PATH 環境変数を介してバッチ ファイルにアクセスできるかどうかはチェック しません。

解決策は、Visual Studio の Tools ディレクトリを指すように VS90COMNTOOLS 変数を定義することです。

そうは言っても、11.4を見てください。distutils.msvccompiler — Python のドキュメントの Microsoft コンパイラ セクション

通常、拡張モジュールは、Python のコンパイルに使用されたのと同じコンパイラでコンパイルする必要があります。

Martin v. Loewis は、python-list メーリング リストでVisual Studio Express 2008 を今すぐダウンロードするというタイトルの電子メールで同じことを述べています。

Python 2.6、2.7、および 3.1 はすべてそのリリース (つまり 2008) でビルドされています。もう 1 つの長い伝統により、Python 拡張モジュールは、Python 自体と同じコンパイラ バージョン (具体的には CRT バージョン) でビルドする必要があります。したがって、これらのリリースの拡張モジュールをビルドするには、VS 2008 または VS 2008 Express のコピーが必要です。

上記のステートメントに照らして、Python 2.7 用の lxml をビルドする場合は VS 2008 を使用する必要があるため、VS90COMNTOOLS を設定すると vcvarsall.bat ファイルが検索されますが、それ解決策ではありません。

そうは言っても :) 人々は新しいコンパイラで古い CRT を使用しようとします:
Visual Studio 2010 の C++ コンパイラを Visual Studio 2008 の C++ ランタイム ライブラリで使用できますか?
特定の CRT バージョンを使用するように C++ コンパイラを強制する方法は?
VS 2008 - 古い C ランタイムとのリンク

スレッドProblem building lxml under Windows - error: Unable lxml メーリング リストで vcvarsall.batを見つけます。distutils に vcvarsall.bat ファイルを探すコードが含まれていることを確認してくれた freenode #distutils IRC チャネルのagronholmにも感謝します。

于 2011-02-25T20:54:42.263 に答える
4

After following the recommended solution:

  1. downloading VCForPython27.msi from Microsoft,
  2. installing it (Win7, Python(x, y) 2.7.9 32bit),
  3. entering / updating the environment variable VS90COMNTOOLS to the installation directory value (C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0)

my problem still existed (want to build a Python extension in C).

I had to do the following 2 unbelievably dirty tweaks, before everything now is indeed working:

  1. modify "msvc9compiler.py" in "C:\Python27\Lib\distutils", function find_vcvarsall, to now point to "Visual C++ for Python" instead of to "VC".
  2. copy the directories founder under "C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0\" to "C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\" (i.e. one dir level up).

I cannot tell who was doing something wrong here - probably I.

EDIT. Moving directories works because of the issue described in this distutils bug.

even if VS90COMNTOOLS is set, msvc9compiler isn't able to find vcvarsall.bat because it is installed in %installdir%/vcvarsall.bat and not %installdir%/VC/vcvarsall.bat

The described workaround is using the Visual C++ command prompt:

  1. Enter MSVC for Python command prompt

  2. SET DISTUTILS_USE_SDK=1

  3. SET MSSdk=1

  4. python.exe setup.py ...

于 2015-01-20T16:28:05.323 に答える
3

Jorj McKie はほぼ正しかったです。実際、VCForPython27.msiをインストールするだけでは十分ではありません。distutils には、find_vcvarsall が見つからないという問題があります。実際、問題は distutils に直接あるのではなく、VCForPython27.msi のパッケージ化方法と vcvarsall.bat の配置場所にあります (フォルダーのレイアウトは VS2008 SDK とは異なります)。

Python 2.7.11 でおそらくパッチが適用されるまでの簡単な回避策: distutils の代わりに setuptools を使用します。

distutils に行き詰まっている場合の別の手動の回避策:

1) Enter MSVC for Python command prompt
2) SET DISTUTILS_USE_SDK=1
3) SET MSSdk=1
4) you can then build your C extensions: python.exe setup.py ...

Gregory Szorc によるバグ報告と回避策: http://bugs.python.org/issue23246

IPython 内で %%cython マジックを使用するための詳細情報と回避策: https://github.com/cython/cython/wiki/CythonExtensionsOnWindows

于 2015-04-05T19:14:43.283 に答える
0

https://github.com/develersrl/gccwinbinaries

同様の問題がありました。これは、インストール ウィザードを使用して 1 つの設定を設定する以外に何もしなくても、すぐに機能しました。

于 2015-07-18T00:33:46.920 に答える