[Mac]安装pyspider的大坑
1.切记这是一个大坑。
2.我在用mac电脑安装pyspider的时候,原以为pip install pyspider 就万事大吉,合家欢乐了,but the question 比较多。
第一个问题:
我一共就遇到这一个问题:所以我就只说这一个问题的解决方法,并且是只针对mac电脑的,其他操作系统的问题,我就解决不了了。
(1)装pyspider
pip3 install pyspider
问题:
Collecting pycurl Downloading http://mirrors.aliyun.com/pypi/packages/e8/e4/0dbb8735407189f00b33d84122b9be52c790c7c3b25286826f4e1bdb7bde/pycurl-7.43.0.2.tar.gz (214kB) 100% |████████████████████████████████| 215kB 1.9MB/s Complete output from command python setup.py egg_info: Using curl-config (libcurl 7.54.0) Traceback (most recent call last): File "<string>", line 1, in <module> File "/private/var/folders/qv/5lbgb8nd7j1_1v_c5hf0h8fm0000gn/T/pip-install-M7SSJd/pycurl/setup.py", line 913, in <module> ext = get_extension(sys.argv, split_extension_source=split_extension_source) File "/private/var/folders/qv/5lbgb8nd7j1_1v_c5hf0h8fm0000gn/T/pip-install-M7SSJd/pycurl/setup.py", line 582, in get_extension ext_config = ExtensionConfiguration(argv) File "/private/var/folders/qv/5lbgb8nd7j1_1v_c5hf0h8fm0000gn/T/pip-install-M7SSJd/pycurl/setup.py", line 99, in __init__ self.configure() File "/private/var/folders/qv/5lbgb8nd7j1_1v_c5hf0h8fm0000gn/T/pip-install-M7SSJd/pycurl/setup.py", line 316, in configure_unix specify the SSL backend manually.''') __main__.ConfigurationError: Curl is configured to use SSL, but we have not been able to determine which SSL backend it is using. Please see PycURL documentation for how to specify the SSL backend manually. ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/qv/5lbgb8nd7j1_1v_c5hf0h8fm0000gn/T/pip-install-M7SSJd/pycurl/
这一堆问题:我当时的想法一只纠结在最后一句上了,其实问题所在和最后一句还有倒数第二句都有关系。
错误信息是Curl is configured to use SSL, but we have not been able to determine which SSL backend it is using. Please see PycURL documentation for how to specify the SSL backend manually,其实就是让我们在安装之前配置openssl的环境变量
解决第一步:brew install openssl
解决第二步:openssl version
显示类似于这样的信息,你就可以说是成功1/3了。
解决第三步:find /usr/local -name ssl.h
只有 中间箭头指向的那个url才是正确的openssl的url。
解决第四步:模仿我的操作添加环境变量
export PYCURL_SSL_LIBRARY=openssl export LDFLAGS=-L/usr/local/Cellar/openssl/1.0.2p/lib export CPPFLAGS=-I/usr/local/Cellar/openssl/1.0.2p/include
添加这三步操作之后。
pip install pycurl
解决第五步: pip3 install pyspider
之后看到的就是这一堆花里胡哨的东西,别管是什么了,前面的successfully看着就很舒服,对吧?
运行 pyspider all 运行成功的话就是如上的一堆。