pycurl 安装问题
项目相关依赖需要安装pycurl. 这时候gunicorn 无法启动。 安装上之后报错。ImportError: pycurl: libcurl link-time ssl backend (none/other) is different from compile-time ssl backend (openssl)
Internal Server Error: /
Traceback (most recent call last):
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/bin/gunicorn", line 11, in <module>
load_entry_point('gunicorn-shopee==19.8.1.3', 'console_scripts', 'gunicorn')()
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 61, in run
WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/gunicorn/app/base.py", line 223, in run
super(Application, self).run()
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/gunicorn/app/base.py", line 72, in run
Arbiter(self).run()
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/gunicorn/arbiter.py", line 189, in run
self.manage_workers()
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/gunicorn/arbiter.py", line 531, in manage_workers
self.spawn_workers()
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/gunicorn/arbiter.py", line 623, in spawn_workers
self.spawn_worker()
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/gunicorn/arbiter.py", line 590, in spawn_worker
worker.init_process()
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/gunicorn/workers/ggevent.py", line 216, in init_process
super(GeventWorker, self).init_process()
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/gunicorn/workers/base.py", line 178, in init_process
self.warm_up()
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/gunicorn/workers/base.py", line 118, in warm_up
warm_up_resp = self.wsgi(warm_up_req, lambda *args, **kwargs: None)
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 206, in __call__
response = self.get_response(request)
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/django/core/handlers/base.py", line 194, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/django/core/handlers/base.py", line 224, in handle_uncaught_exception
'request': request
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/django/core/handlers/base.py", line 99, in get_response
resolver_match = resolver.resolve(request.path_info)
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/django/core/urlresolvers.py", line 337, in resolve
for pattern in self.url_patterns:
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/django/core/urlresolvers.py", line 365, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/django/core/urlresolvers.py", line 360, in urlconf_module
self._urlconf_module = import_module(self.urlconf_name)
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
__import__(name)
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/gevent/builtins.py", line 96, in __import__
result = _import(*args, **kwargs)
File "/Users/guifeng.chen/program/shopee/shopee-logistics-backend/backend/urls.py", line 39, in <module>
(r'^CMS/', include('backend.CMS.urls')),
Internal Server Error: /hen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 26, in include
Traceback (most recent call last):
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/bin/gunicorn", line 11, in <module>
load_entry_point('gunicorn-shopee==19.8.1.3', 'console_scripts', 'gunicorn')()
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/gunicorn/app/wsgiapp.py", line 61, in run
WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/gunicorn/app/base.py", line 223, in run
super(Application, self).run()
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/gunicorn/app/base.py", line 72, in run
Arbiter(self).run()
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/gunicorn/arbiter.py", line 189, in run
self.manage_workers()
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/gunicorn/arbiter.py", line 531, in manage_workers
self.spawn_workers()
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/gunicorn/arbiter.py", line 623, in spawn_workers
self.spawn_worker()
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/gunicorn/arbiter.py", line 590, in spawn_worker
worker.init_process()
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/gunicorn/workers/ggevent.py", line 216, in init_process
super(GeventWorker, self).init_process()
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/gunicorn/workers/base.py", line 178, in init_process
self.warm_up()
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/gunicorn/workers/base.py", line 118, in warm_up
warm_up_resp = self.wsgi(warm_up_req, lambda *args, **kwargs: None)
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 206, in __call__
response = self.get_response(request)
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/django/core/handlers/base.py", line 194, in get_response
response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/django/core/handlers/base.py", line 224, in handle_uncaught_exception
'request': request
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/django/core/handlers/base.py", line 99, in get_response
resolver_match = resolver.resolve(request.path_info)
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/django/core/urlresolvers.py", line 337, in resolve
for pattern in self.url_patterns:
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/django/core/urlresolvers.py", line 365, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/django/core/urlresolvers.py", line 360, in urlconf_module
self._urlconf_module = import_module(self.urlconf_name)
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
__import__(name)
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/gevent/builtins.py", line 96, in __import__
result = _import(*args, **kwargs)
File "/Users/guifeng.chen/program/shopee/shopee-logistics-backend/backend/urls.py", line 39, in <module>
(r'^CMS/', include('backend.CMS.urls')),
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 26, in include
urlconf_module = import_module(urlconf_module)
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module
__import__(name)
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/gevent/builtins.py", line 96, in __import__
result = _import(*args, **kwargs)
File "/Users/guifeng.chen/program/shopee/shopee-logistics-backend/backend/CMS/urls.py", line 3, in <module>
import reload_json_views
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/gevent/builtins.py", line 96, in __import__
result = _import(*args, **kwargs)
File "/Users/guifeng.chen/program/shopee/shopee-logistics-backend/backend/CMS/reload_json_views.py", line 4, in <module>
from backend.utilities.fresh_cache import manual_purge
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/gevent/builtins.py", line 96, in __import__
result = _import(*args, **kwargs)
File "/Users/guifeng.chen/program/shopee/shopee-logistics-backend/backend/utilities/fresh_cache.py", line 4, in <module>
import pycurl, StringIO
File "/Users/guifeng.chen/python/venv/shopee-logistics-backend/lib/python2.7/site-packages/gevent/builtins.py", line 96, in __import__
result = _import(*args, **kwargs)
ImportError: pycurl: libcurl link-time ssl backend (none/other) is different from compile-time ssl backend (openssl)
翻译过来就是链接时候的libcurl和编译时的不同。libcurl 应该是系统组件。可能系统更新导致不可用。这时候我们可以通过更新系统的libcurl, 可能导致系统其它依赖libcurl 的应用大量奔溃,所以。。告辞了。我们应该去重新安装pycurl。
stack overflow
答案
建议指定一些参数
seems like you install pycurl error. if install on centos try this:export PYCURL_SSL_LIBRARY=openssl. if install on macos try this one :
export PYCURL_SSL_LIBRARY=openssl
export LDFLAGS=-L/usr/local/opt/openssl/lib
export CPPFLAGS=-I/usr/local/opt/openssl/include
then run pip install pycurl
按照如上安装还是不行。。。然后放弃治疗。
过了一个月,发现最终还是要面对这个问题。于是开始尝试。
想了一下会不会是没有指定版本,于是登录test容器,一看版本是7.43.0
PYCURL_SSL_LIBRARY=openssl LDFLAGS="-L/usr/local/opt/openssl/lib" CPPFLAGS="-I/usr/local/opt/openssl/include" sudo -H pip install -i http://mirrors.aliyun.com/pypi/simple/ --extra-index-url http://pypi.garenanow.com/ --trusted-host mirrors.aliyun.com --trusted-host pypi.garenanow.com --trusted-host pypi.python.org --no-cache-dir pycurl==7.43.0
bingo~~~