Mac下安装pycurl填坑记录

2019-03-08  本文已影响0人  见字如晤一

在学习python的过程中,安装pyspider时发生错误如下:

➜  ~ pip3 install pyspider
Collecting pyspider
  Using cached https://files.pythonhosted.org/packages/d0/97/d6062c928f53d899ff2a8538fed11d4d425ba3d27c96248a2c601c1c9fef/pyspider-0.3.10.tar.gz
Requirement already satisfied: Flask>=0.10 in /usr/local/lib/python3.7/site-packages (from pyspider) (1.0.2)
Requirement already satisfied: Jinja2>=2.7 in /usr/local/lib/python3.7/site-packages (from pyspider) (2.10)
Requirement already satisfied: chardet>=2.2 in /usr/local/lib/python3.7/site-packages (from pyspider) (3.0.4)
Requirement already satisfied: cssselect>=0.9 in /usr/local/lib/python3.7/site-packages (from pyspider) (1.0.3)
Requirement already satisfied: lxml in /usr/local/lib/python3.7/site-packages (from pyspider) (4.3.2)
Collecting pycurl (from pyspider)
  Using cached https://files.pythonhosted.org/packages/e8/e4/0dbb8735407189f00b33d84122b9be52c790c7c3b25286826f4e1bdb7bde/pycurl-7.43.0.2.tar.gz
    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/s_/y_b63kqj24n62fr1lx4j9h5m0000gn/T/pip-install-ziceo2tz/pycurl/setup.py", line 913, in <module>
        ext = get_extension(sys.argv, split_extension_source=split_extension_source)
      File "/private/var/folders/s_/y_b63kqj24n62fr1lx4j9h5m0000gn/T/pip-install-ziceo2tz/pycurl/setup.py", line 582, in get_extension
        ext_config = ExtensionConfiguration(argv)
      File "/private/var/folders/s_/y_b63kqj24n62fr1lx4j9h5m0000gn/T/pip-install-ziceo2tz/pycurl/setup.py", line 99, in __init__
        self.configure()
      File "/private/var/folders/s_/y_b63kqj24n62fr1lx4j9h5m0000gn/T/pip-install-ziceo2tz/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/s_/y_b63kqj24n62fr1lx4j9h5m0000gn/T/pip-install-ziceo2tz/pycurl/

看意思是openssl的问题,于是开始解决问题:
1、搜索查看openssl的具体位置

➜  ~ sudo find / -iname ssl.h

2、有的时候由于装的环境有多个版本,可能python存在多个ssl.h
可使用指令查看当前是用的是哪个版本和具体位置,然后删除其他无用版本

➜  ~ openssl -versions
➜  ~ whereis openssl

3、若不存在多个版本,可略过第2点
根据我的安装目录是 /usr/local/Cellar/openssl/1.0.2q,然后执行下面三个命令

➜  ~ export PYCURL_SSL_LIBRARY=openssl
➜  ~ export LDFLAGS=-L/usr/local/Cellar/openssl/1.0.2q/lib
➜  ~ export CPPFLAGS=-L/usr/local/Cellar/openssl/1.0.2q/include

4、设置完成后,再次运行安装pyspider指令:

➜  ~ pip3 install pyspider

安装成功!

遇到这个问题也是解决了两天,最终找到正确的解决方式,再次记录一下!
参考:
Mac下安装pycurl填坑记录

上一篇下一篇

猜你喜欢

热点阅读