problem with console

when I write to console py manage.py runserver
console returns python
and does not execute the command, maybe I don’t understand something, looking for help
image

It looks like you’re using Windows Powershell to try and do this, and it doesn’t appear as if you’ve either created or activated a virtual environment.

What steps have you taken before this point? What does py --version show? How about pip list?

<opinion>
You might want to either find a Windows Powershell-specific tutorial or possibly switch to the traditional Windows shell. I find the Windows command prompt to be more “familiar” when trying to use Python/Django than the Powershell.
</opinion>


before this i typed
django-admin startproject mysite


thats i tried to do it all over again

About the best I can tell you is that those steps work for me.

Are you using one of the standard Python distributions or a custom built version? (Hopefully nothing like a “Conda” version or anything like that.) I’ve seen people generally have more success by using one of the standard deployments.

i used last version from official site python 3.11

What does the command py -m pip list show?

How about django-admin?

image

Ok, so this demonstrates a function Python and Django installation.

I’m guessing the next thing to try would be:
py manage.py
to see if you get the same output as the django-admin command.

If so, then try:
py manage.py check

image

Side Note: For future reference, please copy/paste text into your message rather than images. Use lines of three backtick - ` characters to force the forum software to keep it properly formatted. This means you’ll have a line of ```, then your code (or console output), then another line of ```.

Please post your manage.py file here. This almost makes it seem like it wasn’t generated correctly.

#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
    """Run administrative tasks."""
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.settings')
    try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
            "available on your PYTHONPATH environment variable? Did you "
            "forget to activate a virtual environment?"
        ) from exc
    execute_from_command_line(sys.argv)


if __name__ == '__main__':
    main()

Just as an experiment, try deleting that first line from this file.
(The line #!/usr/bin/env python)

I’m kind of able to recreate some of what you’re seeing - and it appears that it may be related to you not using a virtual environment here. (Pure conjecture at this point)

wow this helped solve the problem, thank you very much, but where did I get part of this code from?

It’s generated by the “startproject” command. I don’t understand why it seems to interfere with the py.exe command when you run it outside a venv - but that’s what appears to be happening.

(If you create a venv and activate it, then use it for your startproject, etc, everything appears to work properly. I’m only seeing this problem occur when there’s no active venv.)

Got it, thanks again for your time.