2015-11-01 54 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-混蛋 –