Can't deploy Django app on Python Anywhere: ImportError: No module named 'environ'
Can't deploy Django app on Python Anywhere: ImportError: No module named 'environ'
尝试在 Python 任何地方部署本地 Django 项目,但收到导入错误:当 运行 "python manage.py migrate"
时没有名为 'environ' 的模块
File "/home/Dude1983/surfapp/src/surfapp/settings/development.py",line 1, in <module>
from .base import * # NOQA
File "/home/Dude1983/surfapp/src/surfapp/settings/base.py", line 45,in <module>
import environ
ImportError: No module named 'environ'
我检查了 Django 版本,都是 1.9.5。
我的 wsgi.py 看起来像这样:
import os
import sys
path = '/home/Dude1983/surfapp/' # use your own username here
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'surfapp.settings.production'
from django.core.wsgi import get_wsgi_application
from django.contrib.staticfiles.handlers import StaticFilesHandler
application = StaticFilesHandler(get_wsgi_application())
我使用的是 Edge 2 入门模板,我的设置位于此处:
surfapp
│ ├── __init__.py
│ ├── __pycache__
│ │ └── __init__.cpython-35.pyc
│ ├── logger.py
│ ├── settings
│ │ ├── __init__.py
│ │ ├── __pycache__
│ │ │ ├── __init__.cpython-35.pyc
│ │ │ ├── base.cpython-35.pyc
│ │ │ └── development.cpython-35.pyc
│ │ ├── base.py
│ │ ├── development.py
│ │ ├── local.sample.env
│ │ └── production.py
│ ├── urls.py
│ ├── views.py
│ └── wsgi.py
我已遵循 DjangoGirls 教程 here。
任何人都可以帮助我或给我任何指示吗?
我的猜测是 Edge 2 模板有一些依赖项没有安装在默认的 pythonanywhere 系统中,其中之一叫做 "environ"。
我建议使用 virtualenv,然后执行
pip install -r requirements.txt
(the edge docs 有点令人困惑,但他们确实说,或者至少暗示,你应该像这样做 "pip install")
这里是关于使用 virtualenvs 的 PythonAnywhere 文档:
http://help.pythonanywhere.com/pages/VirtualEnvForNewerDjango
尝试在 Python 任何地方部署本地 Django 项目,但收到导入错误:当 运行 "python manage.py migrate"
时没有名为 'environ' 的模块File "/home/Dude1983/surfapp/src/surfapp/settings/development.py",line 1, in <module>
from .base import * # NOQA
File "/home/Dude1983/surfapp/src/surfapp/settings/base.py", line 45,in <module>
import environ
ImportError: No module named 'environ'
我检查了 Django 版本,都是 1.9.5。
我的 wsgi.py 看起来像这样:
import os
import sys
path = '/home/Dude1983/surfapp/' # use your own username here
if path not in sys.path:
sys.path.append(path)
os.environ['DJANGO_SETTINGS_MODULE'] = 'surfapp.settings.production'
from django.core.wsgi import get_wsgi_application
from django.contrib.staticfiles.handlers import StaticFilesHandler
application = StaticFilesHandler(get_wsgi_application())
我使用的是 Edge 2 入门模板,我的设置位于此处:
surfapp
│ ├── __init__.py
│ ├── __pycache__
│ │ └── __init__.cpython-35.pyc
│ ├── logger.py
│ ├── settings
│ │ ├── __init__.py
│ │ ├── __pycache__
│ │ │ ├── __init__.cpython-35.pyc
│ │ │ ├── base.cpython-35.pyc
│ │ │ └── development.cpython-35.pyc
│ │ ├── base.py
│ │ ├── development.py
│ │ ├── local.sample.env
│ │ └── production.py
│ ├── urls.py
│ ├── views.py
│ └── wsgi.py
我已遵循 DjangoGirls 教程 here。
任何人都可以帮助我或给我任何指示吗?
我的猜测是 Edge 2 模板有一些依赖项没有安装在默认的 pythonanywhere 系统中,其中之一叫做 "environ"。
我建议使用 virtualenv,然后执行
pip install -r requirements.txt
(the edge docs 有点令人困惑,但他们确实说,或者至少暗示,你应该像这样做 "pip install")
这里是关于使用 virtualenvs 的 PythonAnywhere 文档:
http://help.pythonanywhere.com/pages/VirtualEnvForNewerDjango