python 3 django shell ipython bug. ipython shell wouldn't run - django

At some point my project has stoped running IPython shell. ./manage.py shell --plain however still works fine. Unfortunately i don't remember exactly at what moment that happened but it might be due to some packages conflicting with each other. I am running my project in a virtualenv, other virtualenv's with common package set-up work just fine.
Here is the error traceback:
$ ./manage.py shell
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/pk/.virtualenvs/eissvedvl/lib/python3.4/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/home/pk/.virtualenvs/eissvedvl/lib/python3.4/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/pk/.virtualenvs/eissvedvl/lib/python3.4/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/home/pk/.virtualenvs/eissvedvl/lib/python3.4/site-packages/django/core/management/base.py", line 285, in execute
output = self.handle(*args, **options)
File "/home/pk/.virtualenvs/eissvedvl/lib/python3.4/site-packages/django/core/management/base.py", line 415, in handle
return self.handle_noargs(**options)
File "/home/pk/.virtualenvs/eissvedvl/lib/python3.4/site-packages/django/core/management/commands/shell.py", line 81, in handle_noargs
self.run_shell(shell=interface)
File "/home/pk/.virtualenvs/eissvedvl/lib/python3.4/site-packages/django/core/management/commands/shell.py", line 61, in run_shell
return getattr(self, shell)()
File "/home/pk/.virtualenvs/eissvedvl/lib/python3.4/site-packages/django/core/management/commands/shell.py", line 44, in ipython
ip()
File "/home/pk/.virtualenvs/eissvedvl/lib/python3.4/site-packages/django/core/management/commands/shell.py", line 37, in _ipython
from IPython import start_ipython
File "/home/pk/.virtualenvs/eissvedvl/lib/python3.4/site-packages/IPython/__init__.py", line 47, in <module>
from .terminal.embed import embed
File "/home/pk/.virtualenvs/eissvedvl/lib/python3.4/site-packages/IPython/terminal/embed.py", line 35, in <module>
from IPython.terminal.ipapp import load_default_config
File "/home/pk/.virtualenvs/eissvedvl/lib/python3.4/site-packages/IPython/terminal/ipapp.py", line 47, in <module>
from IPython.core.magics import ScriptMagics
File "/home/pk/.virtualenvs/eissvedvl/lib/python3.4/site-packages/IPython/core/magics/__init__.py", line 22, in <module>
from .execution import ExecutionMagics
File "/home/pk/.virtualenvs/eissvedvl/lib/python3.4/site-packages/IPython/core/magics/execution.py", line 27, in <module>
import cProfile as profile
File "/usr/lib/python3.4/cProfile.py", line 22, in <module>
run.__doc__ = _pyprofile.run.__doc__
AttributeError: 'module' object has no attribute 'run'
Here is my requirements.txt:
Django==1.6.5
South==1.0
Werkzeug==0.9.6
django-admin-bootstrapped==1.6.6
django-ajax-selects==1.3.5
django-allauth==0.18.0
django-braces==1.4.0
django-crispy-forms==1.4.0
django-extensions==1.3.11
ipython==2.3.0
oauthlib==0.6.3
psycopg2==2.5.3
requests==2.4.3
requests-oauthlib==0.4.2
six==1.7.3
I would appreciate any help to solve the issue. I have already tried to use different versions of IPython but the shell still wouldn't start.

This maybe in your code package name profile. Refactor your code

Related

Why am I getting errors when trying to invoke Django Python shell?

My current version of python is 2.7.10 and version of Django is 1.9.1, path.py is 8.1.2 but every time when I'm trying to invoke python shell by command:
$ python manage.py shell I'm getting a lot of errors and the ending of them looks like:
Error in sys.excepthook:
Traceback (most recent call last):
File "W:\SVN\vendors\python\win32\lib\site-packages\IPython\CrashHandler.py", line 157, in __call__
report.write(self.make_report(traceback))
File "W:\SVN\vendors\python\win32\lib\site-packages\IPython\CrashHandler.py", line 215, in make_report
rpt_add('BZR revision : %s \n\n' % Release.revision)
AttributeError: 'module' object has no attribute 'revision'
Original exception was:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "W:\SVN\vendors\python\win32\lib\site-packages\django\core\management\__init__.py", line 353, in execute_from_command_line
utility.execute()
File "W:\SVN\vendors\python\win32\lib\site-packages\django\core\management\__init__.py", line 345, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "W:\SVN\vendors\python\win32\lib\site-packages\django\core\management\base.py", line 348, in run_from_argv
self.execute(*args, **cmd_options)
File "W:\SVN\vendors\python\win32\lib\site-packages\django\core\management\base.py", line 399, in execute
output = self.handle(*args, **options)
File "W:\SVN\vendors\python\win32\lib\site-packages\django\core\management\commands\shell.py", line 69, in handle
self.run_shell(shell=options['interface'])
File "W:\SVN\vendors\python\win32\lib\site-packages\django\core\management\commands\shell.py", line 58, in run_shell
return getattr(self, shell)()
File "W:\SVN\vendors\python\win32\lib\site-packages\django\core\management\commands\shell.py", line 41, in ipython
ip()
File "W:\SVN\vendors\python\win32\lib\site-packages\django\core\management\commands\shell.py", line 22, in _ipython_pre_011
shell = IPShell(argv=[])
File "W:\SVN\vendors\python\win32\lib\site-packages\IPython\Shell.py", line 73, in __init__
debug=debug,shell_class=shell_class)
File "W:\SVN\vendors\python\win32\lib\site-packages\IPython\ipmaker.py", line 521, in make_IPython
IP.pre_config_initialization()
File "W:\SVN\vendors\python\win32\lib\site-packages\IPython\iplib.py", line 835, in pre_config_initialization
self.db = pickleshare.PickleShareDB(rc.ipythondir + "/db")
File "W:\SVN\vendors\python\win32\lib\site-packages\IPython\Extensions\pickleshare.py", line 53, in __init__
if not self.root.isdir():
TypeError: _isdir() takes exactly 1 argument (0 given)
How can I overcome the problem?
From doing a quick search, it looks like this error happens when both Django and IPython are installed, since apparently Django will attempt to use the IPython shell.
The first resource with someone who had a similar issue:
run python manage.py shell occurs errors
And in the link above, one of the comments on the OP's question suggested looking at this separate thread for answers:
https://superuser.com/questions/318655/error-running-ipython3-on-xp-typeerror-isdir-takes-exactly-1-argument-0-gi
The winning answer says the following:
Finally decided to give this another stab, and managed to get it to
work. The solution is a two-line change in the
ipython-0.11-py3.2.egg\IPython\utils\pickleshare.py file, line 52:
Before:
if not self.root.isdir():
self.root.makedirs()
After:
if not os.path.isdir(self.root):
os.makedirs(self.root)

Horizon fails to start

I've followed this guide: https://forge.fiware.org/plugins/mediawiki/wiki/fiware/index.php/Identity_Management_-KeyRock-_Installation_and_Administration_Guide
When i run the server i get:
Traceback (most recent call last):
File "manage.py", line 23, in <module>
execute_from_command_line(sys.argv)
File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 261, in fetch_command
commands = get_commands()
File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 107, in get_commands
apps = settings.INSTALLED_APPS
File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 54, in __getattr__
self._setup(name)
File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 49, in _setup
self._wrapped = Settings(settings_module)
File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 132, in __init__
% (self.SETTINGS_MODULE, e)
ImportError: Could not import settings 'openstack_dashboard.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named oslo.utils
I've tried using --pythonpath but to no avail. I've also ran ./run_tests.sh and here are the results: http://pastebin.com/6i7Ws5Ej.
System:
CentOS 6.5 x64,
python 2.6.6
Any idea how to solve this? any info i might have forgotten don’t hesitate to ask
Edit:
I've switched to ubuntu 12 to follow the tutorial step by step. I got keystone running but horizon still fails and gives me the same error.
A fix was also committed on KeyRock's Github account.
Here is the issue.
Manually updating pbr to 1.3.0 directly from python and pip solved all issues

showing syntax error when trying to run in pycharm

When i try to run a project it is showing the following message :
"C:\Program Files (x86)\JetBrains\PyCharm 3.4.1\bin\runnerw.exe" C:\Python27\python.exe G:/project/sample3/manage.py runserver 8000
Traceback (most recent call last):
File "G:/project/sample3/manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python27\lib\site-packages\django-1.7.1-py2.7.egg\django\core\management\__init__.py", line 385, in execute_from_command_line
utility.execute()
File "C:\Python27\lib\site-packages\django-1.7.1-py2.7.egg\django\core\management\__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python27\lib\site-packages\django-1.7.1-py2.7.egg\django\core\management\__init__.py", line 238, in fetch_command
klass = load_command_class(app_name, subcommand)
File "C:\Python27\lib\site-packages\django-1.7.1-py2.7.egg\django\core\management\__init__.py", line 41, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
File "C:\Python27\lib\site-packages\django-1.7.1-py2.7.egg\django\contrib\staticfiles\management\commands\runserver.py", line 18
def get_handler(self, *args, use_static_handler=True, insecure_serving=False, **options):
^
SyntaxError: invalid syntax
Process finished with exit code 1
this happens to all the projects . this problem started unexpectedly...
Looks like you may have accidentally modified the Django code in your installation, because this is not what line 18 of this file looks like in the actual Django source code. Please try to uninstall and reinstall Django.

Django Intro Tutorial - Invoke Python Shell

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.
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.

Cannot successfully merge devserver patches together for deployment to Heroku

I have tried to push my new code to Heroku but I experiencing an ImportError which says:
Starting process with command `python manage.py runserver --insecure 0.0.0.0:13192 --noreload`
Traceback (most recent call last):
execute_from_command_line(sys.argv
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 272, in fetch_command
klass = load_command_class(app_name, subcommand)
File "manage.py", line 10, in <module>
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 453, in execute_from_command_line
File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
from django.core.servers.basehttp import AdminMediaHandler, WSGIServerException, \
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
File "/app/.heroku/python/lib/python2.7/site-packages/devserver/management/commands/runserver.py", line 3, in <module>
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/management/__init__.py", line 77, in load_command_class
utility.execute()
ImportError: cannot import name AdminMediaHandler
I have found in the documentation that django.core.servers.basehttp.AdminMediaHandler from 1.4 would be replaced with django.contrib.staticfiles.handlers.StaticFilesHandler. My question is where do I place the StaticFilesHandler in place of the AdminMediaHandler?
Update:
I have now tried to merge the two patches together by placing git+git://github.com/dcramer/django-devserver#egg=django-devserver in my requirements. But I am still receiving the same error when trying to deploy
No need to try and merge the patches of django-devserver together. Django-devserver 0.5.0 is compatible with Django 1.5, once I placed 'django-deveserver 0.5.0' in my requirements.txt my app could deploy without crashing.