Unable to deploy Django application in Python Anywhere: ImportError: no module named 'environ'

Trying to deploy a local Django project in Python Anywhere, but getting the ImportError module: No module named "environ" when running "python manage.py migrate"

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' 

I checked Django versions as 1.9.5.

My wsgi.py looks like this:

 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()) 

I am using the Edge 2 starter template and my settings are here:

 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 

I followed the DjangoGirls tutorial here .

Can someone help me or give me any directions?

+5
source share
1 answer

I assume that the Edge 2 template has some dependencies that are not installed on the pythonanywhere system by default, and that one of them is called the "environment".

I would suggest using virtualenv and then executed

 pip install -r requirements.txt 

( edge docs are a bit confusing, but they really say, or at least imply, that you should do pip install like this)

Here are the PythonAnywhere docs using virtualenvs:

http://help.pythonanywhere.com/pages/VirtualEnvForNewerDjango

+3
source

Source: https://habr.com/ru/post/1247263/


All Articles