Django1.4 not compatible with Python3.2? - django

I installed Django1.4 on Win 7 with python3.2. But when I run django-admin.py startproject mysite on command prompt I get errors like Syntax error: Invalid Syntax. It shows that there is an error at print ''.join ....... I see that print is missing (). I fixed one Syntax error already.
Is it incomparability issue?
What do you suggest should I do?

Django doesn't officially support Python 3.x yet. Use it with Python 2.7.
Here's the official latest news about Django on Python 3: https://www.djangoproject.com/weblog/2012/mar/13/py3k/
There is an unofficial experiment in supporting Python 3 with a common code base: https://bitbucket.org/vinay.sajip/django/

Related

VS Code + Pylance does not find venv-installed modules while venv is activated

I use VS Code Version: 1.74.3 on MacOS 13.2. python -V returns Python 3.11.1.
I get the following error message: Import "django.shortcuts" could not be resolved from source Pylance(reportMissingModuleScource).
As you can see in the screenshot, the correct venv is activated and includes Django.
I also tried or checked:
Import could not be resolved/could not be resolved from source Pylance in VS Code using Python 3.9.2 on Windows 10
https://stackoverflow.com/a/65802367/2321643 but
the suggested solution with reloading the windows did not help.
reinstallation the virtual environment within VSCode and installing Django again
re-selecting the venv.
deleting all python-specific settings in user/settings.json as well as .vcode/settings.json.
Reinstallation python and associated extensions.
Using Debug I can safely run my Django-application without any import issues. What do I need to do that Pylance does not issues these problems?
My issue was a bug, fixed and closed.
For reference: https://github.com/microsoft/pylance-release/issues/3881
Try clicking on where it says "3.11.1 ('.venv': venv)" (near the bottom right).
It should bring up a little dialog sort of thing at the top where you can verify that the Python path is correct.
Check that it is using the correct Python path. It should be something like venv/bin/python3 or venv/bin/python assuming venv is situated at the root of youur project.

mvpa2.suite: Runtime warning and erro in Python 2.7.6

I just installed mvpa2 module on my ubuntu 14.04, Python 2.7.6. following the instruction at http://www.pymvpa.org/installation.html using sudo aptitude install python-mvpa2
Command import mvpa2 works well, but when I run from mvpa2.suite import * , I get the followin warning in my terminal:
/usr/local/lib/python2.7/dist-packages/sklearn/pls.py:7: DeprecationWarning: This module has been moved to cross_decomposition and will be removed in 0.16
"removed in 0.16", DeprecationWarning)
And also fallowing error:
TypeError: __init__() got an unexpected keyword argument 'rho'
Appreciate your help!
actually this warning comes from the import done by mdp, which PyMVPA optionally uses... you can safely ignore it (no upgrade of PyMVPA would help anyhow), because even if it gets completely removed, then mdp would simply skip that import and you would remain 'golden'.
That problem is due to an incompatibility of the python-mvpa2 and scikit-learn versions. You can check more details on that in this page, because depends on which scikit-learn version you have what will be the parameters to call a given function.
A short solution is to uninstall your python-mvpa2 and scikit-learn, and install them directly from their github repos:
[python-mvpa2] https://github.com/PyMVPA
[scikit-learn] https://github.com/scikit-learn/scikit-learn
I just did it and now the example doc/examples/som.py (for my case) is working perfectly.

Django Install Wierdness - Mac OSX 10.8.5 and Macport Python 2.7.6 - Django/Python/Unix beginner

I've found a lot of posts on Macports/Django install issues but none seem to quite address my situation.
Installed Django using Macports from the command line using
sudo port install py27-django
This seemed to work fine. I opened up IDLE and was able to import django. The following bit of code
import django
from django.core import management
print django.VERSION
returns
(1, 5, 1, 'final', 0)
Which I take to mean I have the final version of Django 1.5.1 installed. So, all seems to be well.
However, now I switch over to my Django tutorial to get learning and I am asked to type this into the command line to confirm that Django is installed:
python -c "import django; print(django.get_version())"
and get the following error:
> File "<string>", line 1, in <module> ImportError: No module named
> django
Some other bits of data. Here's my $PATH:
/Library/Frameworks/Python.framework/Versions/2.7/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin
Finally, the command
django-admin.py startproject mysite
returns
-bash: django-admin.py: command not found
But the command
django-admin-2.7.py startproject mysite
works (creates a new directory called mysite in the working directory). I read somehwere that Macports renames the django-admin file.
I've only been working with Unix for a few weeks so this is a bit confusing. It seems like I have Django on my system, but perhaps the python I am trying to access from my command line is a different python from that which Macports uses.
Any help appreciated!
Dennis
You will need to set your PYTHONPATH environment variable from your terminal to reference your django install. IDLE probably did this for you, but in another shell you'll need to set it. You can set it in your terminal permanently by setting it in ~/.bashrc or ~/.bash_profile (or whatever your terminal shell is).
Your PATH starts with /Library/Frameworks/Python.framework/Versions/2.7/bin so when you type python you get the python in that directory which is the Apple supplied one nut you have installed Django for the Macports one so python does not see it.
To fix you need to have /opt/local/bin earlier on the path than the /Library one. even better remove that /Library entry and use port select python ... to choose which python to run the Macports 2.7 or Apple's or others
As for the django-admin-2.7.py issue, Macports allows you to have several versions of python at once so code depending on eth version has the version add into the script names e.g. you could have a django-admin-2.6.py as well if you installed the py26-django package. This also applies to python itself however python also adds into the port select mechanism so you set a default version.

Django South syncdb gives a SyntaxError

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)

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.