OS X 安装pyspider

pyspider安装的过程中,需要安装pycurl。有几个坑

一、首先遇到权限的问题

因为/Library目录是root权限,所以非root用户对该目录的读写经常会遇到权限问题,但是不宜切换成root用户来安装应用,解决办法命令后面加上“--user”,

原因如下:

Try "python setup.py install --user" You shouldn't use sudo as suggested above for two reasons:

1.You're allowing arbitrary untrusted code off the internet to be run as root

2.Passing the --user flag to python setup.py install will install the package to a user-owned directory.

Your normal non-root user won't be able to access the files installed by sudo pip or sudo python setup.py
二、openssl问题('openssl/ssl.h' file not found)
输入命令:
export PYCURL_SSL_LIBRARY=openssl
pip install pycurl

问题:'openssl/ssl.h' file not found

解决办法:

brew install openssl

配置环境变量

编辑bash_profile

# openssl
LD_LIBRARY_PATH=/usr/local/Cellar/openssl/1.0.2o_2/lib:"${LD_LIBRARY_PATH}"
CPATH=/usr/local/Cellar/openssl/1.0.2o_2/include:"${CPATH}"
PKG_CONFIG_PATH=/usr/local/Cellar/openssl/1.0.2o_2/lib/pkgconfig:"${PKG_CONFIG_PATH}"
export LD_LIBRARY_PATH CPATH PKG_CONFIG_PATH
export LDFLAGS=-L/usr/local/Cellar/openssl/1.0.2o_2/lib
export CPPFLAGS=-I/usr/local/Cellar/openssl/1.0.2o_2/include

保存后,source, 再次执行一遍下面的命令

pip uninstall pycurl# 卸载包
export PYCURL_SSL_LIBRARY=openssl
pip install pycurl --compile --no-cache-dir# 重新编译安装

OK

三、安装pyspider

pip install pyspider --user

参考:https://blog.csdn.net/nellyp/article/details/80110599

 

posted on 2018-08-14 17:26  寻步  阅读(259)  评论(0编辑  收藏  举报