2012-03-24 21 views
1

まず、pip(Mac OS 10.6.8ではPython 2.7.2)を使わずにlxmlをインストールしました。その後、私はthis postを読んで、pip(sudo pip install lxml)を使って再度インストールしました。私はまだ問題がありました:Macでpythonを使ってlxmlをインストール

lxml(import lxml)をインポートできますが、from lxml import etreeは使用できません。私はthese instructions次のソースからlxmlのをインストールしようとし、そして

Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lxml-2.3.3-py2.7-macosx-10.6-intel.egg/lxml/etree.so, 2): Symbol not found: _htmlParseChunk 
    Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lxml-2.3.3-py2.7-macosx-10.6-intel.egg/lxml/etree.so 
    Expected in: flat namespace 
in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/lxml-2.3.3-py2.7-macosx-10.6-intel.egg/lxml/etree.so 

、私はこのエラーメッセージがあります:私はこのエラーメッセージを有する最後

checking whether we are cross compiling... configure: error: in `/Users/my_name/Applications/lxml/lxml-2.2.2/build/tmp/libxml2-2.7.8': 
configure: error: cannot run C compiled programs. 
If you meant to cross compile, use `--host'. 
See `config.log' for more details 
Traceback (most recent call last): 
    File "setup.py", line 115, in <module> 
    STATIC_CFLAGS, STATIC_BINARIES), 
    File "/Users/my_name/Applications/lxml/lxml-2.2.2/setupinfo.py", line 50, in ext_modules 
    libxslt_version=OPTION_LIBXSLT_VERSION) 
    File "/Users/my_name/Applications/lxml/lxml-2.2.2/buildlibxml.py", line 198, in build_libxml2xslt 
    call_subprocess(configure_cmd, cwd=libxml2_dir, **call_setup) 
    File "/Users/my_name/Applications/lxml/lxml-2.2.2/buildlibxml.py", line 158, in call_subprocess 
    raise Exception('Command "%s" returned code %s' % (cmd_desc, returncode)) 
Exception: Command "./configure --without-python --disable-dependency-tracking --disable-shared --prefix=/Users/my_name/Applications/lxml/lxml-2.2.2/build/tmp/libxml2" returned code 1 

を、Iはthis answer及びIの第二のアドバイスに従っコマンドラインsudo STATIC_DEPS=true /usr/bin/easy_install-2.7 lxmlを使用しました。 Appleが提供するPython 2.7のシステムにlxmlをインストールしましたが、現在使用しているバージョンではありません。肯定的な点:Apple-Pythonを実行すると、from lxml import etreeとすることができます。

否定的な点:私はまだpythonの別のバージョンにlxmlをインストールする方法がわかりません。何か案が?

私は現在/Library/Frameworks/Python.framework/Versions/2.7/bin/pythonを使用しています。

+0

の可能な複製を(のhttp:/ /etc/stackoverflow.com/questions/7961577/need-help-installing-lxml-on-os-x-10-7) – bernie

+0

その質問のOSXのバージョンは違いますが、おそらくそこに行くには十分です – bernie

+0

残念なことに、lxmlをからビルドしますソースは機能しません。 – Antonin

答えて

2

使用しているPythonのバージョンに別途easy_installをインストールする必要があります。詳細については、hereの回答を参照してください。そして、あなたはそれを使用してeasy_installコマンドを実行できます。

STATIC_DEPS=true easy_install-2.7 lxml 

はUPDATE:/opt/local/Library/Frameworks:あなたのコメントからは、あなたが今、さらに別のPythonパス、MacPortsのインストールされたPythonのように見えるものを示すパーミッションエラーを報告しています。どのPythonを使いたいのかを理解する必要があります。実際、MacPortsを使用したい場合は、MacPorts提供のlxmlポートをインストールするだけです。それが最も簡単な解決策です。

$ sudo port selfupdate 
$ sudo port install py27-lxml 

そうしないと、他の(python.org?)のPython 2.7.2でeasy_installをインストールする必要があります。私は、Distributeを使用することをお勧めします `setuptoolsのは、より現代的なフォークとあなたは右のPythonの使用していることを確認する必要があります:[OS X 10.7上でlxmlのをインストールする手助けが必要]

$ curl -O http://python-distribute.org/distribute_setup.py 
$ export PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}" 
$ which python2.7 # should be in the path above 
$ python2.7 distribute_setup.py 
$ STATIC_DEPS=true easy_install-2.7 lxml 
+0

最初に、 'sh setuptools-0.6c11-py2.7.egg'を使ってeasy_installをインストールしました(egg [here](http://pypi.python.org/pypi/setuptools#downloads)をダウンロードした後、最後に私はlxmlをインストールしました( 'STATIC_DEPS = true easy_install-2.7 lxml')。 'エラー:インストールディレクトリ内のファイルを作成または削除できません。 ' – Antonin

+0

' [Errno 13]アクセス権が拒否されました: Python.framework/Versions/2.7/lib/python2.7/site-packages/test-easy-install-1180.write-test '} ' – Antonin

+0

ところで、 STATIC_DEPS = true easy_install lxml'?(-2.7なし) – Antonin

関連する問題