尝试在Python Anywhere上部署本地Django项目,但收到ImportError:运行“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。
任何人都可以帮助我或给我任何指示吗?
答案 0 :(得分:4)
我的猜测是Edge 2模板有一些未安装在默认pythonanywhere系统中的依赖项,其中一个被称为“environ”。
我建议使用virtualenv,然后再做
Notification.find().or([
{ sender: userId },
{ recipient: userId }
])
.distinct('conversationId')
.sort('-timestamp')
.limit(LIMIT)
.skip((page - 1) * LIMIT)
.exec(function (error, result) {
return result;
});
(the edge docs有点令人困惑,但是他们确实说,或者至少暗示,你应该做这样的“点子安装”)
以下是使用virtualenvs的PythonAnywhere文档:
http://help.pythonanywhere.com/pages/VirtualEnvForNewerDjango