Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't deploy Django app on Python Anywhere: ImportError: No module named 'environ'

Trying to deploy local Django project on Python Anywhere, but receiving an ImportError: 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've checked the Django versions, both 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'm using the Edge 2 starter template and my settings are located 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 have followed the DjangoGirls tutorial here.

Can anyone help me or give me any pointers?

like image 314
CKP Avatar asked Apr 16 '16 13:04

CKP


1 Answers

My guess is that the Edge 2 template has some dependencies that aren't installed in the default pythonanywhere system, and that one of them is called "environ".

I would suggest using a virtualenv, and then doing a

pip install -r requirements.txt

(the edge docs are a bit confusing, but they do say, or at least imply, you should be doing a "pip install" like this)

Here are the PythonAnywhere docs on using virtualenvs:

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

like image 180
hwjp Avatar answered Nov 15 '22 10:11

hwjp