我在Mac上运行Falcon遇到了挑战。我使用python 2.7和pycharm一段时间没有问题。
似乎有几个相关的帖子here,here和here,但似乎仍有同样的问题。
我花了很多时间试图让它工作,所有内容似乎都指向六个包和SSL。
以下是我迄今为止的努力。任何帮助非常感谢
MYMACBOOKPRO:falcon my.user$ sw_vers -productVersion
10.10.2
MYMACBOOKPRO:falcon my.user$ python --version
Python 2.7.10
MYMACBOOKPRO:falcon my.user$ pip install six --upgrade
Requirement already up-to-date: six in /Library/Python/2.7/site-packages
MYMACBOOKPRO:falcon my.user$ sudo pip install pyopenssl ndg-httpsclient
Password:
The directory '/Users/my.user/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/my.user/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied (use --upgrade to upgrade): pyopenssl in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
Requirement already satisfied (use --upgrade to upgrade): ndg-httpsclient in /Library/Python/2.7/site-packages
MYMACBOOKPRO:falcon my.user$ sudo pip install six --upgrade
The directory '/Users/my.user/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/my.user/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already up-to-date: six in /Library/Python/2.7/site-packages
MYMACBOOKPRO:falcon my.user$ sudo pip install pyopenssl ndg-httpsclient
The directory '/Users/my.user/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/my.user/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already satisfied (use --upgrade to upgrade): pyopenssl in /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python
Requirement already satisfied (use --upgrade to upgrade): ndg-httpsclient in /Library/Python/2.7/site-packages
MYMACBOOKPRO:falcon my.user$ openssl version
OpenSSL 1.0.2d 9 Jul 2015
MYMACBOOKPRO:falcon my.user$ sudo pip install gunicorn --upgrade
The directory '/Users/my.user/Library/Caches/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/Users/my.user/Library/Caches/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Requirement already up-to-date: gunicorn in /Library/Python/2.7/site-package
MYMACBOOKPRO:falcon my.user$ cat things.py
# things.py
# Let's get this party started
import falcon
# Falcon follows the REST architectural style, meaning (among
# other things) that you think in terms of resources and state
# transitions, which map to HTTP verbs.
class ThingsResource:
def on_get(self, req, resp):
"""Handles GET requests"""
resp.status = falcon.HTTP_200 # This is the default status
resp.body = ('\nTwo things awe me most, the starry sky '
'above me and the moral law within me.\n'
'\n'
' ~ Immanuel Kant\n\n')
# falcon.API instances are callable WSGI apps
app = falcon.API()
# Resources are represented by long-lived class instances
things = ThingsResource()
# things will handle all requests to the '/things' URL path
app.add_route('/things', things)
MYMACBOOKPRO:falcon my.user$ gunicorn things:app
[2015-11-20 08:38:42 -0500] [66479] [INFO] Starting gunicorn 19.3.0
[2015-11-20 08:38:42 -0500] [66479] [INFO] Listening at: http://127.0.0.1:8000 (66479)
[2015-11-20 08:38:42 -0500] [66479] [INFO] Using worker: sync
[2015-11-20 08:38:42 -0500] [66482] [INFO] Booting worker with pid: 66482
[2015-11-20 08:38:42 -0500] [66482] [ERROR] Exception in worker process:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
worker.init_process()
File "/Library/Python/2.7/site-packages/gunicorn/workers/base.py", line 118, in init_process
self.wsgi = self.app.wsgi()
File "/Library/Python/2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/Library/Python/2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/Library/Python/2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/Library/Python/2.7/site-packages/gunicorn/util.py", line 355, in import_app
__import__(module)
File "/Users/my.user/falcon/things.py", line 4, in <module>
import falcon
File "/Library/Python/2.7/site-packages/falcon/__init__.py", line 32, in <module>
from falcon.api import API, DEFAULT_MEDIA_TYPE # NOQA
File "/Library/Python/2.7/site-packages/falcon/api.py", line 22, in <module>
from falcon.request import Request, RequestOptions
File "/Library/Python/2.7/site-packages/falcon/request.py", line 35, in <module>
from six.moves.http_cookies import SimpleCookie
ImportError: No module named http_cookies
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/gunicorn/arbiter.py", line 507, in spawn_worker
worker.init_process()
File "/Library/Python/2.7/site-packages/gunicorn/workers/base.py", line 118, in init_process
self.wsgi = self.app.wsgi()
File "/Library/Python/2.7/site-packages/gunicorn/app/base.py", line 67, in wsgi
self.callable = self.load()
File "/Library/Python/2.7/site-packages/gunicorn/app/wsgiapp.py", line 65, in load
return self.load_wsgiapp()
File "/Library/Python/2.7/site-packages/gunicorn/app/wsgiapp.py", line 52, in load_wsgiapp
return util.import_app(self.app_uri)
File "/Library/Python/2.7/site-packages/gunicorn/util.py", line 355, in import_app
__import__(module)
File "/Users/my.user/falcon/things.py", line 4, in <module>
import falcon
File "/Library/Python/2.7/site-packages/falcon/__init__.py", line 32, in <module>
from falcon.api import API, DEFAULT_MEDIA_TYPE # NOQA
File "/Library/Python/2.7/site-packages/falcon/api.py", line 22, in <module>
from falcon.request import Request, RequestOptions
File "/Library/Python/2.7/site-packages/falcon/request.py", line 35, in <module>
from six.moves.http_cookies import SimpleCookie
ImportError: No module named http_cookies
[2015-11-20 08:38:42 -0500] [66482] [INFO] Worker exiting (pid: 66482)
Traceback (most recent call last):
File "/usr/local/bin/gunicorn", line 11, in <module>
sys.exit(run())
File "/Library/Python/2.7/site-packages/gunicorn/app/wsgiapp.py", line 74, in run
WSGIApplication("%(prog)s [OPTIONS] [APP_MODULE]").run()
File "/Library/Python/2.7/site-packages/gunicorn/app/base.py", line 189, in run
super(Application, self).run()
File "/Library/Python/2.7/site-packages/gunicorn/app/base.py", line 72, in run
Arbiter(self).run()
File "/Library/Python/2.7/site-packages/gunicorn/arbiter.py", line 174, in run
self.manage_workers()
File "/Library/Python/2.7/site-packages/gunicorn/arbiter.py", line 477, in manage_workers
self.spawn_workers()
File "/Library/Python/2.7/site-packages/gunicorn/arbiter.py", line 541, in spawn_workers
time.sleep(0.1 * random.random())
File "/Library/Python/2.7/site-packages/gunicorn/arbiter.py", line 214, in handle_chld
self.reap_workers()
File "/Library/Python/2.7/site-packages/gunicorn/arbiter.py", line 459, in reap_workers
raise HaltServer(reason, self.WORKER_BOOT_ERROR)
gunicorn.errors.HaltServer: <HaltServer 'Worker failed to boot.' 3>
答案 0 :(得分:0)
您的环境可能有问题。我使用Mac,我从来没有遇到过问题。为了确保,请尝试使用virtualenv。
pip install virtualenv
virtualenv test
source ./test/bin/activate
pip install falcon
pip install gunicorn
cd go/to/your/falcon/app/path
gunicorn things:app
如果它不起作用,请尝试重新安装pip。如果有效,请告诉我。
答案 1 :(得分:0)
运行命令:
$ pip install falcon
将安装falcon版本0.3.0
,其中包含错误:ImportError: No module named http_cookies
然后像这样安装软件包:
$ pip install falcon-1.0.0rc1.tar.gz