# problem with console

**URL:** <https://forum.djangoproject.com/t/problem-with-console/18250>\
**Category:** Getting Started\
**Created:** [January 17, 2023, 3:54pm UTC](https://forum.djangoproject.com/t/problem-with-console/18250 "2023-01-17T15:54:17Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![dimaselih](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/dimaselih/32/11802_2.png) [@dimaselih](https://forum.djangoproject.com/u/dimaselih)\
**Post date:** [January 17, 2023, 3:54pm UTC](https://forum.djangoproject.com/t/problem-with-console/18250/1 "2023-01-17T15:54:17Z")

</div>

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](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/9/9b446a409ef2517cbc1f41bc4d577f8003fef63c.png)

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [January 17, 2023, 5:13pm UTC](https://forum.djangoproject.com/t/problem-with-console/18250/2 "2023-01-17T17:13:06Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dimaselih](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/dimaselih/32/11802_2.png) [@dimaselih](https://forum.djangoproject.com/u/dimaselih)\
**Post date:** [January 17, 2023, 5:22pm UTC](https://forum.djangoproject.com/t/problem-with-console/18250/3 "2023-01-17T17:22:29Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/4/41380443ce8a9ad7bfac584afb20264d82cf236d.png)  
before this i typed  
django-admin startproject mysite

---

<div class="post-metadata">

**Author:** ![dimaselih](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/dimaselih/32/11802_2.png) [@dimaselih](https://forum.djangoproject.com/u/dimaselih)\
**Post date:** [January 17, 2023, 5:30pm UTC](https://forum.djangoproject.com/t/problem-with-console/18250/4 "2023-01-17T17:30:11Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/7/785da3132e92cfff541eda4b49f47c08ee5b009c.png)  
thats i tried to do it all over again

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [January 17, 2023, 5:43pm UTC](https://forum.djangoproject.com/t/problem-with-console/18250/5 "2023-01-17T17:43:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dimaselih](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/dimaselih/32/11802_2.png) [@dimaselih](https://forum.djangoproject.com/u/dimaselih)\
**Post date:** [January 17, 2023, 5:52pm UTC](https://forum.djangoproject.com/t/problem-with-console/18250/6 "2023-01-17T17:52:05Z")

</div>

i used last version from official site python 3.11

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [January 17, 2023, 5:53pm UTC](https://forum.djangoproject.com/t/problem-with-console/18250/7 "2023-01-17T17:53:27Z")

</div>

What does the command `py -m pip list` show?

How about `django-admin`?

---

<div class="post-metadata">

**Author:** ![dimaselih](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/dimaselih/32/11802_2.png) [@dimaselih](https://forum.djangoproject.com/u/dimaselih)\
**Post date:** [January 17, 2023, 6:02pm UTC](https://forum.djangoproject.com/t/problem-with-console/18250/8 "2023-01-17T18:02:16Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/1/1c32a99ddce31d3d770cf36752d20c3afe258bfd.png)

---

<div class="post-metadata">

**Author:** ![dimaselih](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/dimaselih/32/11802_2.png) [@dimaselih](https://forum.djangoproject.com/u/dimaselih)\
**Post date:** [January 17, 2023, 6:07pm UTC](https://forum.djangoproject.com/t/problem-with-console/18250/9 "2023-01-17T18:07:41Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/e/eaf1e005a5f52109217867fd9288215b535b5715.png)

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [January 17, 2023, 6:31pm UTC](https://forum.djangoproject.com/t/problem-with-console/18250/10 "2023-01-17T18:31:17Z")

</div>

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`

---

<div class="post-metadata">

**Author:** ![dimaselih](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/dimaselih/32/11802_2.png) [@dimaselih](https://forum.djangoproject.com/u/dimaselih)\
**Post date:** [January 17, 2023, 6:44pm UTC](https://forum.djangoproject.com/t/problem-with-console/18250/11 "2023-01-17T18:44:58Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/7/784ad2f10550b7cfb3f43c42d37f8d922998e889.png)

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [January 17, 2023, 7:00pm UTC](https://forum.djangoproject.com/t/problem-with-console/18250/12 "2023-01-17T19:00:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dimaselih](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/dimaselih/32/11802_2.png) [@dimaselih](https://forum.djangoproject.com/u/dimaselih)\
**Post date:** [January 17, 2023, 7:15pm UTC](https://forum.djangoproject.com/t/problem-with-console/18250/13 "2023-01-17T19:15:09Z")

</div>

```auto
#!/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()

```

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [January 17, 2023, 7:35pm UTC](https://forum.djangoproject.com/t/problem-with-console/18250/14 "2023-01-17T19:35:14Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![dimaselih](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/dimaselih/32/11802_2.png) [@dimaselih](https://forum.djangoproject.com/u/dimaselih)\
**Post date:** [January 17, 2023, 7:57pm UTC](https://forum.djangoproject.com/t/problem-with-console/18250/15 "2023-01-17T19:57:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [January 17, 2023, 8:02pm UTC](https://forum.djangoproject.com/t/problem-with-console/18250/16 "2023-01-17T20:02:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dimaselih](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/dimaselih/32/11802_2.png) [@dimaselih](https://forum.djangoproject.com/u/dimaselih)\
**Post date:** [January 17, 2023, 8:04pm UTC](https://forum.djangoproject.com/t/problem-with-console/18250/17 "2023-01-17T20:04:26Z")

</div>

Got it, thanks again for your time.
