2015-11-01 56 views
1

我用pip install scrapy安裝scrapyscrapy無法加載libxslt.1.dylib我的Mac

但我跑得scrapy得到如下錯誤:

➜ source scrapy  
Traceback (most recent call last): 
    File "/usr/local/bin/scrapy", line 7, in <module> 
    from scrapy.cmdline import execute 
    File "/Library/Python/2.7/site-packages/scrapy/__init__.py", line 48, in <module> 
    from scrapy.spiders import Spider 
    File "/Library/Python/2.7/site-packages/scrapy/spiders/__init__.py", line 10, in <module> 
    from scrapy.http import Request 
    File "/Library/Python/2.7/site-packages/scrapy/http/__init__.py", line 11, in <module> 
    from scrapy.http.request.form import FormRequest 
    File "/Library/Python/2.7/site-packages/scrapy/http/request/form.py", line 9, in <module> 
    import lxml.html 
    File "/Library/Python/2.7/site-packages/lxml/html/__init__.py", line 42, in <module> 
    from lxml import etree 
ImportError: dlopen(/Library/Python/2.7/site-packages/lxml/etree.so, 2): Library not loaded: /opt/local/lib/libxslt.1.dylib 
    Referenced from: /Library/Python/2.7/site-packages/lxml/etree.so 
    Reason: image not found 

很奇怪scrapy找libxslt.1。 dylib在我的/ opt/floder ...

我跑pip install scrapy,得到這樣的:

➜ ~ pip install scrapy 
Requirement already satisfied (use --upgrade to upgrade): scrapy in /Library/Python/2.7/site-packages 
Requirement already satisfied (use --upgrade to upgrade): cssselect>=0.9 in /Library/Python/2.7/site-packages (from scrapy) 
Requirement already satisfied (use --upgrade to upgrade): queuelib in /Library/Python/2.7/site-packages (from scrapy) 
Requirement already satisfied (use --upgrade to upgrade): pyOpenSSL in /Library/Python/2.7/site-packages (from scrapy) 
Requirement already satisfied (use --upgrade to upgrade): w3lib>=1.8.0 in /Library/Python/2.7/site-packages (from scrapy) 
Requirement already satisfied (use --upgrade to upgrade): lxml in /Library/Python/2.7/site-packages (from scrapy) 
Requirement already satisfied (use --upgrade to upgrade): Twisted>=10.0.0 in /Library/Python/2.7/site-packages (from scrapy) 
Requirement already satisfied (use --upgrade to upgrade): six>=1.5.2 in /Library/Python/2.7/site-packages (from scrapy) 
Requirement already satisfied (use --upgrade to upgrade): service-identity in /Library/Python/2.7/site-packages (from scrapy) 
Requirement already satisfied (use --upgrade to upgrade): cryptography>=0.7 in /Library/Python/2.7/site-packages (from pyOpenSSL->scrapy) 
Requirement already satisfied (use --upgrade to upgrade): zope.interface>=3.6.0 in /Library/Python/2.7/site-packages (from Twisted>=10.0.0->scrapy) 
Requirement already satisfied (use --upgrade to upgrade): characteristic>=14.0.0 in /Library/Python/2.7/site-packages (from service-identity->scrapy) 
Requirement already satisfied (use --upgrade to upgrade): pyasn1-modules in /Library/Python/2.7/site-packages (from service-identity->scrapy) 
Requirement already satisfied (use --upgrade to upgrade): pyasn1 in /Library/Python/2.7/site-packages (from service-identity->scrapy) 
Requirement already satisfied (use --upgrade to upgrade): setuptools in /usr/local/lib/python2.7/site-packages (from cryptography>=0.7->pyOpenSSL->scrapy) 
Requirement already satisfied (use --upgrade to upgrade): enum34 in /Library/Python/2.7/site-packages (from cryptography>=0.7->pyOpenSSL->scrapy) 
Requirement already satisfied (use --upgrade to upgrade): ipaddress in /Library/Python/2.7/site-packages (from cryptography>=0.7->pyOpenSSL->scrapy) 
Requirement already satisfied (use --upgrade to upgrade): idna>=2.0 in /Library/Python/2.7/site-packages (from cryptography>=0.7->pyOpenSSL->scrapy) 
Requirement already satisfied (use --upgrade to upgrade): cffi>=1.1.0 in /Library/Python/2.7/site-packages (from cryptography>=0.7->pyOpenSSL->scrapy) 
Requirement already satisfied (use --upgrade to upgrade): pycparser in /Library/Python/2.7/site-packages (from cffi>=1.1.0->cryptography>=0.7->pyOpenSSL->scrapy) 

幫助!!

更新於2015/11/06

嗨,喬楊。

我試試這個brew install libxml2 libxslt。但它不工作,好像我蟒的樣子道路是錯誤的?

➜ haimi git:(V3.2.0) brew install libxml2 libxslt 
Warning: libxml2-2.9.2 already installed 
Warning: libxslt-1.1.28_1 already installed 
➜ haimi git:(V3.2.0) ✗ scrapy 
Traceback (most recent call last): 
    File "/usr/local/bin/scrapy", line 7, in <module> 
    from scrapy.cmdline import execute 
    File "/Library/Python/2.7/site-packages/scrapy/__init__.py", line 48, in <module> 
    from scrapy.spiders import Spider 
    File "/Library/Python/2.7/site-packages/scrapy/spiders/__init__.py", line 10, in <module> 
    from scrapy.http import Request 
    File "/Library/Python/2.7/site-packages/scrapy/http/__init__.py", line 11, in <module> 
    from scrapy.http.request.form import FormRequest 
    File "/Library/Python/2.7/site-packages/scrapy/http/request/form.py", line 9, in <module> 
    import lxml.html 
    File "/Library/Python/2.7/site-packages/lxml/html/__init__.py", line 42, in <module> 
    from lxml import etree 
ImportError: dlopen(/Library/Python/2.7/site-packages/lxml/etree.so, 2): Library not loaded: /opt/local/lib/libxslt.1.dylib 
    Referenced from: /Library/Python/2.7/site-packages/lxml/etree.so 
    Reason: image not found 
➜ haimi git:(V3.2.0) ✗ 
+0

請更新您的問題,'不能mac'運行過於寬泛 – eLRuLL

+0

好吧,我將更新它!謝謝。 – user3875388

回答

1

聽起來你需要libxslt和libxml庫,這是scrapy所需的lxml python包所必需的。

如果您安裝了「X代碼命令行工具包」,它應該爲您包含這些庫。這裏有一個指南:http://quantgreeks.com/how-to-install-xcode-command-line-tools-in-osx-yosemite/

本質上,它歸結爲運行:

xcode-select --install 
+0

感謝您的回答! 我試過這個,在'xcode-select --install'之後安裝了「X-code命令行工具包」。 安裝後運行'xcode-select --install',得到: 'xcode-select:error:命令行工具已經安裝,使用「軟件更新」安裝更新程序',但問題沒有解決。我的英文是pool ... – user3875388

+0

你可以嘗試用自制軟件安裝它,如果你有'brew install libxml2 libxslt' https://github.com/sparklemotion/nokogiri/wiki/What-to-do-if-libxml2-是幸福-A-混蛋 –