Django South syncdb gives a SyntaxError - django

I installed South using pip.
Following the official guide (http://south.readthedocs.org/en/latest/installation.html#installation)
I add 'south', to my installed_apps, run manage.py syncdb, get this:
*Long Traceback ending in south\management\commands\syncdb.py, line 52
except Import Error, exc:
SyntaxError: invalid syntax
Take south away, run syncdb, everything is fine. What gives?
UPDATE: South only works on Python 2.x so installing 2.7 did the trick. Thank you IRC.

I do not know what you may have done wrong, but to do the work you need to just south of 3 small steps, described previously by you.
1) pip install south
2) Add the 'south' in your INSTALLED_APPS the end of all "django.contrib"
3) run python manage.py syncdb
With these steps your syncdb will be different and, from this point forward, you should normally use the south.
I did a video recently (in Portuguese), showing how to install and run south with a project already started, maybe this video can help you http://bit.ly/XffRGy

I got the same error using python 3.2.3. I my case this is a non-backwards compatible change from python 2.*. I went to the source file and deleted the ", exc" you will find at the end of an except statement. This fixed the error in question, however you will get more errors from there. I tried running 2to3 on the whole south directory and and not getting and code specific errors anymore. Unfortunalty I am now getting and error "NameError: global name 'exc' is not defined" but with no traceback. I have been stuck here for a while, but at least this is progress. I will report if I get this thing working.
[Check here for info regarding the specific incompatibility. Under the heading "Changes Already Present In Python 2.6"]
(http://docs.python.org/release/3.1.3/whatsnew/3.0.html)

Related

ImportError sayins module dot not exist, but is already installed

I had to install new package on my project to handle with Base64 images from my API, so i installed django-extra-fields, so far so good, i have made my testes locally, everything working just fine, when i pushed my changes to production and installed the new package running pip install django-extra-fields with right virtualenv on, i just keep getting the error ImportError at /
No module named drf_extra_fields.fields
That seens a silly mistake, so i checked my code like 100 times so far, and everything is right
I'm using Django 1.11 with Python 2.7
My vm is called: vm-prod_cfr_nuvem
When i run pip freeze show all my packages:
(vm-prod_cfr_nuvem) [~ site-packages]$ pip freeze
Django==1.11.6
django-cors-headers==2.1.0
django-extra-fields==2.0.2
django-filter==1.1.0
And if i enter in vm site-packages path, i can see that is installed there
/home/daniloitj/.virtualenvs/vm-prod_cfr_nuvem/lib/python2.7/site-packages
django_cors_headers-2.1.0.dist-info
django_extra_fields-2.0.2.dist-info
django_filter-1.1.0.dist-info
on my view where the show the error, as you can see, is the same path as the last one in list
ImportError at /
No module named drf_extra_fields.fields
...
Python Path:
['/home/daniloitj/webapps/cfr_prod/lib/python2.7/Django-1.11.9-py2.7.egg',
'/home/daniloitj/webapps/cfr_prod',
'/home/daniloitj/webapps/cfr_prod/cfr_nuvem',
'/home/daniloitj/webapps/cfr_prod/lib/python2.7',
'/home/daniloitj/lib/python2.7',
'/home/daniloitj/lib/python2.7',
'/home/daniloitj/.virtualenvs/vm-prod_cfr_nuvem/lib64/python27.zip',
'/home/daniloitj/.virtualenvs/vm-prod_cfr_nuvem/lib64/python2.7',
'/home/daniloitj/.virtualenvs/vm-prod_cfr_nuvem/lib64/python2.7/plat-linux2',
'/home/daniloitj/.virtualenvs/vm-prod_cfr_nuvem/lib64/python2.7/lib-tk',
'/home/daniloitj/.virtualenvs/vm-prod_cfr_nuvem/lib64/python2.7/lib-old',
'/home/daniloitj/.virtualenvs/vm-prod_cfr_nuvem/lib64/python2.7/lib-dynload',
'/usr/lib64/python2.7',
'/usr/lib/python2.7',
'/usr/lib64/python2.7/lib-tk',
'/home/daniloitj/.virtualenvs/vm-prod_cfr_nuvem/lib/python2.7/site-packages']
Obs.: I thought that somehow my server is not using my VM or something like it... so i activate it manually on my terminal and run python manage.py shell and tried to import the lib import drf_extra_fields im still getting the same error
Obs2.: Didnt found anyone with same problem using that lib, and there is no issues about it, so probabily is my misconfiguration rather than something broke in the lib
Package Page: https://github.com/Hipo/drf-extra-fields
That error make me crazy... i solved it going back 1 small version... so instead of using 2.0.2 i'm using 2.0.1, the odd thing is... the 2.0.2 still working on my local environment, but dont work on production, and dont seems be environment problem cuz my server match all requirements to use that lib

Error on Pycharm: ImportError

I'm, working on Windows 8 and I receive this error when launching my python program on pycharm:
ImportError: No module named Qwt5
refered to the line: "import PyQt4.Qwt5 as Qwt"
the program always worked till today, and the IDE still suggests me Qwt5 as a module to import when pressing CTRL+SPACE, so it seems is still recognized.
I checked the Qwt5 folder and there is the __init__.py file
I use Python 2.7.9 an is correctly selected as Python Interpreter
I've already tried to remove the packages and reinstall them.
Someone can help me?
i tried this and working.sudo apt-get install python-qwt5-qt4

How to overcome ImportError: cannot import name XXXX

I have pulled some working Django code from a repo and am trying to set up my local windows 7 dev environment. I have what I think is a suitable version of Python (2.7.6) and a copy of Django 1.5.4.
When I tried python manage.py runserver, I got various ImportErrors.
One by one, I did a pip install XXXX and they went away.
But now I am stuck with this error;
ImportError: cannot import name parse_html_config
I'm only a few days into Python & Django so am unclear - but I think this import is part of commandtools package, so I did pip install commandtools. I got the message that commandtools was already installed.
When I search my project, I can't find from XXXX import parse_html_config anyway, so I don't know where to look next, can anyone help please?
The whole output is;
(swoopenv) C:\django workspace\swoopenv\swoop\swoop>python manage.py runserver
C:\Python27\Lib\site-packages\django\core\management\__init__.py:465: DeprecationWarning: The 'execute_manager' function is deprecated, you
likely need to update your 'manage.py'; please see the Django 1.4 release notes (https://docs.djangoproject.com/en/dev/releases/1.4/).
DeprecationWarning)
C:\Python27\Lib\site-packages\django\core\management\__init__.py:409: DeprecationWarning: The 'setup_environ' function is deprecated, you li
kely need to update your 'manage.py'; please see the Django 1.4 release notes (https://docs.djangoproject.com/en/dev/releases/1.4/).
DeprecationWarning)
C:\Python27\Lib\site-packages\django\conf\__init__.py:221: DeprecationWarning: You have no filters defined on the 'mail_admins' logging hand
ler: adding implicit debug-false-only filter. See http://docs.djangoproject.com/en/dev/releases/1.4/#request-exceptions-are-now-always-logge
d
DeprecationWarning)
ImportError: cannot import name parse_html_config

Django: Can not get django-admin.py to run anything

System: Windows 7x64
Django v. 1.4
Python v. 3.2
First time working with Django or python and I am beating my head against the wall. I have installed everything for Django according to the install instructions. The only step I skipped was the 'optional' virtualenv installation.
I am attempting to run the tutorial on djangoproject.com and I can't get startproject to work. Here is my issues.
When attempting to use 'django-admin.py startproject mysite' or even just 'django-admin.py help' functions I get the following:
Traceback (most recent call last):
File "C:\Python32\Scripts\django-admin.py", line 2, in
from django.core import management File "C:\Python32\lib\site-packages\django\core\management__init__.py",
line 54
except ImportError,e:
^
SyntaxError: invalid syntax
Where the ^ is pointing to the comma.
I have checked the permissions for the folder I am in and everything appears to be good there. What am I doing wrong?
Django doesn't work with Python 3 (yet).
Install 2.7 instead.
You might also stick to Python 3.X and get django 1.5 that is currently in beta phase.
Python 3.3 offers experimental support. django-admin.py still won't run properly, but here's a workaround for you:
You can call the django-admin subcommands directly from your own python script.
from django.core import management
management.call_command("startproject", "mysite")
Almost everything else should be done from the manage.py file it generates, which should work fine with:
python manage.py runserver
or whatever command you're looking for. You may also be using "python33" instead of python.
General answer: that syntax line isn't valid in Python 3.2 (Django doesn't work with Python 3 yet). Here's a list of the 2.x versions you can use with particular versions of Django.
Specific answer: According to PEP-3110, the syntax for exceptions changed from except Exception, e to except Exception as e in Python 3, which is why that error's showing up.

Django extensions error message

Im a django beginner and am using it on a windows machine. Now when i run 'python manage.py runserver', im getting the following message :
"Error: No module named django_extensions"
Any way to fix this ?
Thank You
Look inside your settings.py file under the INSTALLED_APPS setting and delete "django_extensions". Or you can install django_extensions in this environment.
You're testing a Django application right ? (one you didn't write). It seems you miss some dependencies (at least this one).
You might be able to install it throw easy_install or by executing the setup.py of the following package (django-extension).
You also have to check if you have django_extension in your INSTALLED_APPS settings variable, but I'm not quite sure it is needed for django-extension..
Anyway, you might want to install this package : django-extension