0

我在 Mac 上运行 Falcon 时遇到了挑战。我使用 python 2.7 和 pycharm 一段时间没有问题。

这里这里这里似乎有几个相关的帖子,但似乎仍然有同样的问题。

我花了很多时间试图让它工作,一切似乎都指向六个包和 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>
4

2 回答 2

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。让我知道它是否有效。

于 2016-03-25T19:12:59.090 回答
0

运行命令:

$ pip install falcon

0.3.0将安装给出错误的falcon 版本:ImportError: No module named http_cookies

使用来自python.org的包安装 falcon

然后像这样安装包:

$ pip install falcon-1.0.0rc1.tar.gz

于 2016-04-03T22:23:42.523 回答