PythonAnywhere Forums

"ImportError,e" Syntax Error - Existing Django Project Migrating to Pythonanywhere

I am new to Python and Django. I have an existing Django/Python project, which I am trying to deploy to Python Anywhere, given I need to pull some data for work. I followed the thread - https://help.pythonanywhere.com/pages/DeployExistingDjangoProject/, to help the process.

Everything is working fine, until I get to migrating the old DB to my VirtualEnv setup. I get an error message


Traceback (most recent call last): File "./manage.py", line 2, in <module> from django.core.management import execute_manager File "/home/sqhan/.virtualenvs/bbproject-virtualenv/lib/python3.4/site-packages/django/core/management/init.py", line 52 except ImportError,e: ^ SyntaxError: invalid syntax


Any guidance on how to resolve the matter would be greatly appreciated. I have made sure the Django versions from previous project match with the one install on the virtualenv.

Thanks.

SalK

You're on the right track in thinking about versions -- but the error you're seeing is due to a Python version mismatch, not a Django version one. It looks like your code has been written for Python 2.7, and your virtualenv is Python 3.x. If you delete the virtualenv and re-create it with Python 2.7, that error should go away.

Thank you for your help. I deleted the old virtualenv and created a new one with Python 2.7 ver. Now when I try to migrate the DB, I get the following error message:

(bbproject-virtualenv) 15:36 ~/bbproject $ ./manage.py migrate Traceback (most recent call last): File "./manage.py", line 2, in <module> from django.core.management import execute_manager ImportError: No module named django.core.management

Do I need to reinstall Django again? Please help!

Yes. You need to install the correct version of DJango and all of the other packages that your web app uses into the virtualenv.