DJANGO_PATH errors and settings issues - django

I recently upgraded my Ubuntu to 14.04, and consulted this question to solve my erros, ImportError: No module named _io in ubuntu 14.04. That was solved perfectly.
I also checked out this question as it's similar to mine, Consistently getting ImportError: Could not import settings 'myapp.settings' error, but could not use the same solution.
I do not use manage.py in my project and I have done numerous exports of the PYTHON_PATH to no end of my issues. Here is my traceback;
Traceback (most recent call last):
File "/home/thabang/.virtualenvs/lottostar/bin/django-admin.py", line 5, in <module>
management.execute_from_command_line()
File "/home/thabang/.virtualenvs/lottostar/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/home/thabang/.virtualenvs/lottostar/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/thabang/.virtualenvs/lottostar/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command
commands = get_commands()
File "/home/thabang/.virtualenvs/lottostar/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 107, in get_commands
apps = settings.INSTALLED_APPS
File "/home/thabang/.virtualenvs/lottostar/local/lib/python2.7/site-packages/django/conf/__init__.py", line 54, in __getattr__
self._setup(name)
File "/home/thabang/.virtualenvs/lottostar/local/lib/python2.7/site-packages/django/conf/__init__.py", line 49, in _setup
self._wrapped = Settings(settings_module)
File "/home/thabang/.virtualenvs/lottostar/local/lib/python2.7/site-packages/django/conf/__init__.py", line 132, in __init__
% (self.SETTINGS_MODULE, e)
ImportError: Could not import settings 'lottostar.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named lottostar.settings

I found the problem:
The was an issue with the egg files during the virtualenv reinstall. Though the programs were there, they couldn't be found. I just performed another install of the requirements to refresh the egg info.

Related

Django can't find package even though in virtualenv

I'm coming into an inherited Django project, so I can't say how it was originally set up. However, pip freeze tells me that django-cms is installed in the virtualenv:
(demo)$ pip freeze
...
django-cms==3.3.0
...
So why when I do anything with, manage.py, do I get an error saying it's not available?
(demo)$
./manage.py shell
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/iscape/sites/demo/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
utility.execute()
File "/iscape/sites/demo/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 328, in execute
django.setup()
File "/iscape/sites/demo/local/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/iscape/sites/demo/local/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/iscape/sites/demo/local/lib/python2.7/site-packages/django/apps/config.py", line 112, in create
mod = import_module(mod_path)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named cms
I can also confirm that VIRTUAL_ENV has the correct value in the "activate" script. It's like pip knows what's installed, but Django doesn't.
This is Django1.8, btw, though I don't know how much of a factor that is.
Any ideas? I'm getting nothing out of the stack trace and don't know where else to look.

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

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

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

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.