0

I am new to django and am starting to go through the documenation and the poll tutorial. Install etc has been no problem and I have gotten as far as creating and activating the simple model however I am now trying to invoke the Python shell using

python manage.py shell

but I keep getting the below error each time.

C:\Users\Owner\Desktop\Programming\Djang\mysite>python manage.py shell
Traceback (most recent call last):
 File "manage.py", line 10, in <module>
 execute_from_command_line(sys.argv)
 File "C:\python27\lib\site-packages\django\core\management\__init__.py", line
399, in execute_from_command_line
 utility.execute()
 File "C:\python27\lib\site-packages\django\core\management\__init__.py", line
392, in execute
 self.fetch_command(subcommand).run_from_argv(self.argv)
 File "C:\python27\lib\site-packages\django\core\management\base.py", line 242,
 in run_from_argv
 self.execute(*args, **options.__dict__)
 File "C:\python27\lib\site-packages\django\core\management\base.py", line 285,
 in execute
 output = self.handle(*args, **options)
 File "C:\python27\lib\site-packages\django\core\management\base.py", line 415,
 in handle
 return self.handle_noargs(**options)
 File "C:\python27\lib\site-packages\django\core\management\commands\shell.py",
 line 81, in handle_noargs
 self.run_shell(shell=interface)
 File "C:\python27\lib\site-packages\django\core\management\commands\shell.py",
 line 61, in run_shell
 return getattr(self, shell)()
 File "C:\python27\lib\site-packages\django\core\management\commands\shell.py",
 line 44, in ipython
 ip()
 File "C:\python27\lib\site-packages\django\core\management\commands\shell.py",
 line 37, in _ipython
 from IPython import start_ipython
 File "C:\python27\lib\site-packages\IPython\__init__.py", line 43, in <module>
 from .config.loader import Config
 File "C:\python27\lib\site-packages\IPython\config\__init__.py", line 16, in <
module>
 from .application import *
 File "C:\python27\lib\site-packages\IPython\config\application.py", line 29, i
n <module>
 from IPython.external.decorator import decorator
 File "C:\python27\lib\site-packages\IPython\external\decorator\__init__.py", l
ine 4, in <module>
 from ._decorator import *
 File "C:\python27\lib\site-packages\IPython\external\decorator\_decorator.py",
 line 165
 print('Error in generated code:', file=sys.stderr)
 ^
SyntaxError: invalid syntax

Thanks in advance for any help on this as although I have some experience in Python I'm finding it very hard to follow the Traceback above.

asked May 26, 2014 at 6:57
1
  • It looks like you have python3 code in your python2 library. you cannot do that. Where did you get that IPython install? Commented May 26, 2014 at 7:04

1 Answer 1

1

You are using a Python 3 library (and not backward compatible) with the Python 2.7 version. You need either to reinstall ipython for Python 2 (in C:\python27) or upgrade to Python 3 (and install ipython in C:\python3)

Django is officially compatible with Python 3 since the 1.6 version.

answered May 26, 2014 at 7:07
Sign up to request clarification or add additional context in comments.

2 Comments

That worked for me thank you very much. From my perspective is there anything in the Traceback above that would have made it obvious that there was an issue with compatibility (so I can know for again)?
@user3675339 The hint there was the fact there is C:\python27 in your path and the error occurred on the print line, because it became a function in Python 3: docs.python.org/3.0/whatsnew/3.0.html#print-is-a-function Don't forget to accept the answer if it helps you :) meta.stackexchange.com/questions/5234/…

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.