Re: Problems with first tutorial

146 views
Skip to first unread message

Snorre Edwin

unread,
Aug 28, 2012, 5:21:05 AM8/28/12
to django...@googlegroups.com
It didnt seem to work. All i get is the error:

C:\Prosjekter\Djangotest\testproject>python manage.py shell
ImportError: No module named user

Maybe i do it from the wrong directory, this is my buildtree:

Djangotest>testproject>testproject(have settings.py and everything created with djangoadmin),polls(have models, views and stuff),manage.py

If first tried to create the batch file in the first testproject folder, the one above where manage.py is. That didnt work.
I also tried to move it down to the next folder and it didnt work there either.
This is the batch file i wrote:

set TESTPROJECT_HOME=%CD%
set DJANGO_SETTINGS_MODULE=testproject.settings
set PYTHONPATH=%TESTPROJECT_HOME%

Any clue why it doesnt work?

On Tuesday, August 28, 2012 4:53:58 AM UTC+2, trebor63 wrote:

I hope this helps, when working under windows (XP/7) this just works for me.

Replace <project> with whatever you have named it.

From the directory above where the project was created create a batch file (ie <project>.bat) containing the following

set <project>_HOME=%CD%

set DJANGO_SETTINGS_MODULE=<project>.settings

set PYTHONPATH=%<project>_HOME%


You can add any other additional pythonpath requirements with the delimiter of a semicolon ‘;’

 

You could also hardcode the “<project>_HOME” variable, but this is up to you

 

Once done the following should work for you via the command prompt.

 

Run the batch file above from the directory it was created in

<project>

cd <project>

manage.py shell


On Tuesday, 28 August 2012 09:01:25 UTC+10, Snorre Edwin wrote:
Im on the Playing with the API part and seem to catch some troubles.
Everything has gone smoothly until this part.

I write this and get the next error. This is with my enviromen_variable: DJANGO_SETTINGS_MODULE set to where I can find the settings.py in my project.

C:\Prosjekter\Djangotest\testproject>python manage.py shell
ImportError: Could not import settings 'C:\Prosjekter\Djangotest\testproject\testproject' (Is it on sys.path?): Import by filename is not supported.

With out the env variable I get this error:
C:\Prosjekter\Djangotest\testproject>python manage.py shell
ImportError: No module named user

I have done the sync part and I can see that the postgreSQL have the tables in its database.
I have also done everything right until this part.

As i understood, I did not have to set env variable when I used python manage.py shell.

Can someone help me please:)

Melvyn Sopacua

unread,
Aug 28, 2012, 5:46:38 AM8/28/12
to django...@googlegroups.com
On 28-8-2012 11:21, Snorre Edwin wrote:
> It didnt seem to work. All i get is the error:
>
> C:\Prosjekter\Djangotest\testproject>python manage.py shell
> ImportError: No module named user

The traceback should show where the import error is raised:
python manage.py shell --traceback

--
Melvyn Sopacua

Snorre Edwin

unread,
Aug 28, 2012, 5:52:35 AM8/28/12
to django...@googlegroups.com
C:\Prosjekter\Djangotest\testproject>python manage.py shell --traceback
Traceback (most recent call last):
  File "C:\Python32\lib\site-packages\django\core\management\commands\shell.py", line 64, in handle_noargs
    self.run_shell(shell=interface)
  File "C:\Python32\lib\site-packages\django\core\management\commands\shell.py", line 48, in run_shell
    raise ImportError
ImportError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python32\lib\site-packages\django\core\management\base.py", line 222, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "C:\Python32\lib\site-packages\django\core\management\base.py", line 252, in execute
    output = self.handle(*args, **options)
  File "C:\Python32\lib\site-packages\django\core\management\base.py", line 382, in handle
    return self.handle_noargs(**options)
  File "C:\Python32\lib\site-packages\django\core\management\commands\shell.py", line 92, in handle_noargs
    import user
ImportError: No module named user
ImportError: No module named user


Does it make any sense to you?

Melvyn Sopacua

unread,
Aug 28, 2012, 8:06:53 AM8/28/12
to django...@googlegroups.com
On 28-8-2012 11:52, Snorre Edwin wrote:

> "C:\Python32\lib\site-packages\django\core\management\commands\shell.py",
> line 92, in handle_noargs
> import user
> ImportError: No module named user
> ImportError: No module named user
>
>
> Does it make any sense to you?

It makes sense, since my guess is that you have Python 3.2 installed.
Django 1.4 does not support python 3.x, only 2.5 through 2.7. Django 1.5
will be the first release supporting Python 3.x.

--
Melvyn Sopacua

Snorre Edwin

unread,
Aug 28, 2012, 10:06:28 AM8/28/12
to django...@googlegroups.com
I
It makes sense, since my guess is that you have Python 3.2 installed.
Django 1.4 does not support python 3.x, only 2.5 through 2.7. Django 1.5
will be the first release supporting Python 3.x.

--
Melvyn Sopacua

It doesnt make much sense when i have django version 1.5:
C:\Prosjekter\Djangotest\testproject>django-admin.py version
1.5

Any other clues to what this might be? 

William Stearns

unread,
Aug 28, 2012, 1:05:01 PM8/28/12
to django...@googlegroups.com
Latest released version is 1.4.1.  So, there is no release of 1.5 at the moment.  With the development branch, if and when it breaks, you get to keep the pieces.

CG

unread,
Oct 2, 2012, 6:52:06 PM10/2/12
to django...@googlegroups.com
Sorry for the late reply since I saw this only now. I also have the dev version of Django installed and ran into this error.
Seems like this is an error in the django code. I was able to bypass this and fire up the shell by just commenting
the 'import user' line in shell.py in ../django/core/management/commands/shell.py.

- Cheers,
Chandrakant

Russell Keith-Magee

unread,
Oct 2, 2012, 7:39:03 PM10/2/12
to django...@googlegroups.com
On Wed, Oct 3, 2012 at 6:52 AM, CG <chandraka...@gmail.com> wrote:
> Sorry for the late reply since I saw this only now. I also have the dev
> version of Django installed and ran into this error.
> Seems like this is an error in the django code. I was able to bypass this
> and fire up the shell by just commenting
> the 'import user' line in shell.py in
> ../django/core/management/commands/shell.py.

You could also fix the problem by using a current revision of the
development checkout. The line you refer to was removed on August 29
as part of the Python 3 changes.

If you're just getting started, I'd strongly recommend against working
against the development version. While we aim for it to be stable,
there will sometimes be problems. Your learning experience will be
much better if you use a stable version (1.4.1 at present).

Yours,
Russ Magee %-)

CG

unread,
Oct 3, 2012, 1:19:20 AM10/3/12
to django...@googlegroups.com
Hi Russ,
Thanks for the warning. I have actually worked a little with django before so am not a starter. I work with Python 3 on a daily basis and am more interested in getting django to work with it. Hence I am using the dev version. Thanks for the input. I will get the latest asap.
Reply all
Reply to author
Forward
0 new messages