0

I have a Django "project" that I have inherited, which I am developing in Eclipse. On my OS (windows 7 32 bit), I have Python 2.7.4 installed, likewise for my virtualenv. However, on my project (extracted from SVN) the Python version is 2.7 only.

This causes a conflict when trying to create another superuser (I do not know the original superuser name/password) where I get the message:

cannot import maxrepeat

How do I upgrade the python version located at:

c:\users\"username"\workspace\"project"\scripts

from 2.7 to 2.7.4?

Apologies if I have omitted some important details, or if I am asking the wrong question as I am newbie to Django/python development.

EDIT
Having spoken to a friend before referring back to these responses (thanks btw), he advised me to copy over the contents of the 'scripts' folder within my virtualenv to the folder:

c:\users\"username"\workspace\"project"\scripts

I did that, so in theory, they are both now running from python version 2.7.4.

However, when I run the script

python manage.py createsuperuser

I get the following FULL Traceback:

Traceback (most recent call last):
  File "manage.py", line 10, in 
    execute_from_command_line(sys.argv)
  File "C:\users\alecc\workspace\hub\lib\site-packages\django\core\management\__init__.py"
, line 453, in execute_from_command_line
    utility.execute()
  File "C:\users\alecc\workspace\hub\lib\site-packages\django\core\management\__init__.py"
, line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "C:\users\alecc\workspace\hub\lib\site-packages\django\core\management\__init__.py"
, line 263, in fetch_command
    app_name = get_commands()[subcommand]
  File "C:\users\alecc\workspace\hub\lib\site-packages\django\core\management\__init__.py"
, line 109, in get_commands
    apps = settings.INSTALLED_APPS
  File "C:\users\alecc\workspace\hub\lib\site-packages\django\conf\__init__.py", line 53,
in __getattr__
    self._setup(name)
  File "C:\users\alecc\workspace\hub\lib\site-packages\django\conf\__init__.py", line 48,
in _setup
    self._wrapped = Settings(settings_module)
  File "C:\users\alecc\workspace\hub\lib\site-packages\django\conf\__init__.py", line 134,
 in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SE
TTINGS_MODULE, e))
ImportError: Could not import settings 'hub.settings' (Is it on sys.path?): No module name
d hub.settings

I have checked the system variables and I'm sure my project is on the Python system path. I have also checked 'django.contrib.auth' is enabled in my INSTALLED_APPS in the settings.pyfile.

Edit 2
Many other posts suggest it's a cross over of Python versions. However when I check the version number using the command:

$scripts\python.exe --version

I get Python 2.7.4 for each installation (Project & virtualenv)

1 Answers1

0

Based on this information:

File "C:\users\alecc\workspace\hub\lib\site-packages\django\conf\__init__.py", line 134,
 in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SE
TTINGS_MODULE, e))
ImportError: Could not import settings 'hub.settings' (Is it on sys.path?): No module name
d hub.settings

It looks like your application is called hub? The problem here is that it's trying to import hub.settings - but it can't find it. So for some reason, your settings.py is not on the path.

You can check this by editing C:\users\alecc\workspace\hub\lib\site-packages\django\conf\__init__.py, and somewhere before line 134 you can put import sys; print(sys.path). Then check to see that the path where your settings.py file lives is available. If it is, something else weird is happening.

If not, just go ahead and pull those lines from the __init__, and try running manage from the same directory your settings file is in.

Wayne Werner
  • 49,299
  • 29
  • 200
  • 290
  • Thanks! I would give you an up vote if I had the necessary rep. – Alec Christie Oct 21 '13 at 08:27
  • My app is called hub you're correct (I should have explained that). Trying to check where `settings.py` file was lead me to realise it was looking for a folder, within the application, called hub. Therfore, it was trying to find a file `hub/hub/__init__.py` and couldn't. Annoyingly, the error didn't indicate this. I also didn't realise it was a requirement to have this folder, named after the application itself, within the root destination, containing a `___init__.py` file. I just created it and.. voila! – Alec Christie Oct 21 '13 at 08:33
  • It *did* actually indicate it, just in a slightly more esoteric way ;) It's a bit of a hard problem to know exactly what you were trying to do, so it gave the best answer it could give - somewhere it tried to `import hub.settings` (or maybe `__import__('hub.settings')`). Python really has no clue about Django, or what the intended project structure is supposed to look like - only about imports. Glad it helped! – Wayne Werner Oct 23 '13 at 15:41