python爬虫

MacOS 环境下安装PySpider、PyCurl

2018-09-20  本文已影响139人  夏威夷的芒果

如果想安装PySpider,必先安装PyCurl,但是MacOS环境下,安装PyCurl常常出错。
我把错误的信息贴上来,方便以后此文被搜索引擎收录之后,搜索的各位可以尽快解决问题。

问题描述

pip3 install pyspider

然后控制台跳出来告诉我PyCurl出错了,好奇怪。那么我就试试

pip3 install pycurl

结果报了一大堆这个错误。

Collecting pycurl
  Using cached https://files.pythonhosted.org/packages/e8/e4/0dbb8735407189f00b33d84122b9be52c790c7c3b25286826f4e1bdb7bde/pycurl-7.43.0.2.tar.gz
Building wheels for collected packages: pycurl
  Running setup.py bdist_wheel for pycurl ... error
  Complete output from command /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/md/fr36tv350nxf3m2dc7hy2j640000gn/T/pip-install-13ofoswt/pycurl/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /private/var/folders/md/fr36tv350nxf3m2dc7hy2j640000gn/T/pip-wheel-yo86nduk --python-tag cp36:
  Using curl-config (libcurl 7.52.1)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.macosx-10.6-intel-3.6
  creating build/lib.macosx-10.6-intel-3.6/curl
  copying python/curl/__init__.py -> build/lib.macosx-10.6-intel-3.6/curl
  running build_ext
  building 'pycurl' extension
  creating build/temp.macosx-10.6-intel-3.6
  creating build/temp.macosx-10.6-intel-3.6/src
  /usr/bin/clang -fno-strict-aliasing -Wsign-compare -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -I/usr/local/opt/openssl/include# -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_OPENSSL=1 -DHAVE_CURL_SSL=1 -I/Codes/anaconda/include -I/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c src/docstrings.c -o build/temp.macosx-10.6-intel-3.6/src/docstrings.o
  In file included from src/docstrings.c:4:
  In file included from src/pycurl.h:32:
  In file included from /Codes/anaconda/include/curl/curl.h:39:
  /Codes/anaconda/include/curl/curlrules.h:143:6: error: '__curl_rule_01__' declared as an array with a negative size
      [CurlchkszEQ(long, CURL_SIZEOF_LONG)];
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /Codes/anaconda/include/curl/curlrules.h:132:27: note: expanded from macro 'CurlchkszEQ'
  #define CurlchkszEQ(t, s) sizeof(t) == s ? 1 : -1
                            ^~~~~~~~~~~~~~~~~~~~~~~
  /Codes/anaconda/include/curl/curlrules.h:153:6: error: '__curl_rule_02__' declared as an array with a negative size
      [CurlchkszEQ(curl_off_t, CURL_SIZEOF_CURL_OFF_T)];
       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /Codes/anaconda/include/curl/curlrules.h:132:27: note: expanded from macro 'CurlchkszEQ'
  #define CurlchkszEQ(t, s) sizeof(t) == s ? 1 : -1
                            ^~~~~~~~~~~~~~~~~~~~~~~
  2 errors generated.
  error: command '/usr/bin/clang' failed with exit status 1
  
  ----------------------------------------
  Failed building wheel for pycurl
  Running setup.py clean for pycurl
Failed to build pycurl
Installing collected packages: pycurl
  Running setup.py install for pycurl ... error
    Complete output from command /Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/md/fr36tv350nxf3m2dc7hy2j640000gn/T/pip-install-13ofoswt/pycurl/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/md/fr36tv350nxf3m2dc7hy2j640000gn/T/pip-record-_chu5ou9/install-record.txt --single-version-externally-managed --compile:
    Using curl-config (libcurl 7.52.1)
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.6-intel-3.6
    creating build/lib.macosx-10.6-intel-3.6/curl
    copying python/curl/__init__.py -> build/lib.macosx-10.6-intel-3.6/curl
    running build_ext
    building 'pycurl' extension
    creating build/temp.macosx-10.6-intel-3.6
    creating build/temp.macosx-10.6-intel-3.6/src
    /usr/bin/clang -fno-strict-aliasing -Wsign-compare -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -I/usr/local/opt/openssl/include# -DPYCURL_VERSION="7.43.0.2" -DHAVE_CURL_SSL=1 -DHAVE_CURL_OPENSSL=1 -DHAVE_CURL_SSL=1 -I/Codes/anaconda/include -I/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c src/docstrings.c -o build/temp.macosx-10.6-intel-3.6/src/docstrings.o
    In file included from src/docstrings.c:4:
    In file included from src/pycurl.h:32:
    In file included from /Codes/anaconda/include/curl/curl.h:39:
    /Codes/anaconda/include/curl/curlrules.h:143:6: error: '__curl_rule_01__' declared as an array with a negative size
        [CurlchkszEQ(long, CURL_SIZEOF_LONG)];
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Codes/anaconda/include/curl/curlrules.h:132:27: note: expanded from macro 'CurlchkszEQ'
    #define CurlchkszEQ(t, s) sizeof(t) == s ? 1 : -1
                              ^~~~~~~~~~~~~~~~~~~~~~~
    /Codes/anaconda/include/curl/curlrules.h:153:6: error: '__curl_rule_02__' declared as an array with a negative size
        [CurlchkszEQ(curl_off_t, CURL_SIZEOF_CURL_OFF_T)];
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Codes/anaconda/include/curl/curlrules.h:132:27: note: expanded from macro 'CurlchkszEQ'
    #define CurlchkszEQ(t, s) sizeof(t) == s ? 1 : -1
                              ^~~~~~~~~~~~~~~~~~~~~~~
    2 errors generated.
    error: command '/usr/bin/clang' failed with exit status 1
    
    ----------------------------------------
Command "/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 -u -c "import setuptools, tokenize;__file__='/private/var/folders/md/fr36tv350nxf3m2dc7hy2j640000gn/T/pip-install-13ofoswt/pycurl/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /private/var/folders/md/fr36tv350nxf3m2dc7hy2j640000gn/T/pip-record-_chu5ou9/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/md/fr36tv350nxf3m2dc7hy2j640000gn/T/pip-install-13ofoswt/pycurl/

解决

这个问题我花了1小时来研究试了各种方法,最后在stackoverflow这里找到了解决办法,

Ok, there is definitely some challenges to build Pycurl. Here are the steps I took:

完美解决。

上一篇下一篇

猜你喜欢

热点阅读