无法运行Cloned Flask / Heroku应用程序

时间:2014-12-10 16:08:13

标签: python heroku flask virtualenv

我一直在使用笔记本电脑A来构建Flask / Heroku应用程序。现在已切换到笔记本电脑B,我正试图让应用程序在本地运行。我已经设置了Heroku并将我的应用程序克隆到B.每当我尝试运行应用程序时python run.py ...

(venv)admins-MacBook-Air:lhv-talenttracker surajkapoor$ python run.py
Traceback (most recent call last):
  File "run.py", line 1, in <module>
    from app import app
  File "/Users/surajkapoor/Desktop/lhv-talenttracker/app/__init__.py", line 7, in <module>
    import views
  File "/Users/surajkapoor/Desktop/lhv-talenttracker/app/views.py", line 2, in <module>
    from utils import mandatory_fields_filled, allowed_file, get_activation_link, get_serializer, drop_candidate_on_page, email_to_resumename, role_to_integer, create_bio_field, parse_bio, parse_status, parse_role, get_filename_extension, extract_company_domain, file_upload, candidate_formgrab, analytics_parse_point_in_process, commit_to_analytics, attach_resume_send_email, add_candidate_to_requested, admin_required
  File "/Users/surajkapoor/Desktop/lhv-talenttracker/app/utils.py", line 3, in <module>
    from flask.ext.mail import Message, Mail
  File "/Library/Python/2.7/site-packages/flask/exthook.py", line 87, in load_module
    raise ImportError('No module named %s' % fullname)
ImportError: No module named flask.ext.mail

所以我运行pip install Flask-Mail和...

(venv)admins-MacBook-Air:lhv-talenttracker surajkapoor$ pip install Flask-Mail
Downloading/unpacking Flask-Mail
  Downloading Flask-Mail-0.9.1.tar.gz (45kB): 45kB downloaded
  Running setup.py (path:/private/var/folders/fy/q_qrg7h16_710hs0qs05pp6m0000gq/T/pip_build_surajkapoor/Flask-Mail/setup.py) egg_info for package Flask-Mail

    warning: no previously-included files matching '*.pyc' found under directory 'docs'
    warning: no previously-included files matching '*.pyo' found under directory 'docs'
    no previously-included directories found matching 'docs/_build'
    no previously-included directories found matching 'docs/_themes/.git'
Requirement already satisfied (use --upgrade to upgrade): Flask in /Library/Python/2.7/site-packages (from Flask-Mail)
Downloading/unpacking blinker (from Flask-Mail)
  Downloading blinker-1.3.tar.gz (91kB): 91kB downloaded
  Running setup.py (path:/private/var/folders/fy/q_qrg7h16_710hs0qs05pp6m0000gq/T/pip_build_surajkapoor/blinker/setup.py) egg_info for package blinker

Requirement already satisfied (use --upgrade to upgrade): Werkzeug>=0.7 in /Library/Python/2.7/site-packages (from Flask->Flask-Mail)
Requirement already satisfied (use --upgrade to upgrade): Jinja2>=2.4 in /Library/Python/2.7/site-packages (from Flask->Flask-Mail)
Requirement already satisfied (use --upgrade to upgrade): itsdangerous>=0.21 in /Library/Python/2.7/site-packages (from Flask->Flask-Mail)
Requirement already satisfied (use --upgrade to upgrade): markupsafe in /Library/Python/2.7/site-packages (from Jinja2>=2.4->Flask->Flask-Mail)
Installing collected packages: Flask-Mail, blinker
  Running setup.py install for Flask-Mail
    error: /Library/Python/2.7/site-packages/flask_mail.py: Permission denied
    Complete output from command /usr/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/fy/q_qrg7h16_710hs0qs05pp6m0000gq/T/pip_build_surajkapoor/Flask-Mail/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/fy/q_qrg7h16_710hs0qs05pp6m0000gq/T/pip-jJZpzO-record/install-record.txt --single-version-externally-managed --compile:
    running install

running build

running build_py

creating build

creating build/lib

copying flask_mail.py -> build/lib

running install_lib

copying build/lib/flask_mail.py -> /Library/Python/2.7/site-packages

error: /Library/Python/2.7/site-packages/flask_mail.py: Permission denied

----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/fy/q_qrg7h16_710hs0qs05pp6m0000gq/T/pip_build_surajkapoor/Flask-Mail/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/fy/q_qrg7h16_710hs0qs05pp6m0000gq/T/pip-jJZpzO-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /private/var/folders/fy/q_qrg7h16_710hs0qs05pp6m0000gq/T/pip_build_surajkapoor/Flask-Mail
Storing debug log for failure in /Users/surajkapoor/Library/Logs/pip.log
(venv)admins-MacBook-Air:lhv-talenttracker surajkapoor$ 

我在虚拟环境中看到了Flask-Mail,所以我对如何运行它感到困惑。我也尝试过安装我的requirements.txt,但这似乎没什么用。

1 个答案:

答案 0 :(得分:0)

通过激活virtualenv运行pip来检查which pip的来源。它应该在virtualenv中(您可以检查python以获得良好的衡量标准。)

相反,你的pip正在尝试将内容安装到你的全局python安装中,并且它被拒绝权限(正常情况下,没有root权限 - 这很好,这就是我们使用virtualenv的原因)。

确保您拥有最新的virtualenv(&gt; = 1.10)和pip(&gt; = 1.5)。如果你没有,重新安装它们并重新创建你用旧版本制作的任何虚拟版。或者也许你的virtualenv在制作时包含了全球网站套餐?这通常也不是你想要的。