Path Problem Path Problem

I am working my way through the w3schools tutorial.

I have just successfully installed Django but when I try to set up the Project it says that the command I am using is not valid. I think there is a path problem.

I have included a screen capture.



at the Python prompt, try this for test purposes:

import os

What do you get?

Remember that you can always check your PYTHONPATH via:

def get_my_python_path():
    import sys
    PATHS = sys.path
    num = 1
    print('\nMy PYTHONPATH: Where Python searches when importing modules (lower number takes precedence):')
    for path in PATHS:
        print('{}. {}'.format(num, path))
        num += 1

Installing Django may put some useful “scripts” (programs that you can run at the command line) in the scripts sub-directory of your Python installation. However, if you are using the Python launcher (with py), generally this is because that folder isn’t listed in your PATH environment variable - so you can’t just run those scripts by name. The same folder is where Pip lives - it’s exactly as the warning says.

The Windows installer does not add these paths to PATH by default, for very carefully considered reasons. See previous discussion:

And some other resources:

If you don’t want to add the scripts folder to PATH, you can run the programs by specifying their path (either relative or absolute) at the command line - for example:

C:\Users\donca> appdata\local\programs\python\python312\Scripts\django-admin startproject my_tennis_club


Thank you for your help.
After more than a few false starts I have got my mind around how the folders work in a dos environment.
I have also figured out how to set up the Paths using the Windows Environment tools.
And I have made it to the web page that says I have the Django web page working.

I now have a problem with django.shortcuts. I am going to start a new topic because my original problems have all been solved.

Thank you to and Paul for all your help.


I got stuck on the first line.
I am including a screen capture.

From your screenshot, you are attempting to execute Python commands in the DOS command window. I don’t believe this is allowed. Go to your PyCharm window IDE editor and execute the commands there.


I have run this code in PyCharm:

from django.shortcuts import render
from django.http import HttpResponse

def members(request):
    return HttpResponse("Hello world!")

I get an Exit Code of 0 which I think is good but there is no result.

See screen capture below.


I have run this code in PyCharm:

from django.shortcuts import render
from django.http import HttpResponse

def members(request):
   return HttpResponse("Hello world!")

I get an Exit Code of 0 which I think is good but there is no result.

Yes, 0 is the good exit code. The (many) possible nonzero exits
represent failure. On the premise that there are many ways to fail. For
a few things this matters, for most things failure just uses 1 as the
exit code.

See screen capture below.

Please copy/paste text where possible - it makes it possible for use to
also copy/paste the text. Sometimes a screenshot is useful eg to confirm
you’re in the right tool (eg DOS prompt vs Python prompt, etc) or to
show an image. But we prefer text.

The reason nothing happens is that the code above only:

  • imports some modules (which you were having trouble with before, so
    knowing that’s working is good)
  • defines a function

Both of those things are silent. And you don’t call the function, so
it is never run, just defined.

Great! By the way, what is the purpose of the request parameter in the members function definition? If you define a function with parameters (in your case one parameter → request), it implies that arguments are going to be passed in, in place of these parameters when calling the function.

For example,

def some_function(x, y):  # parameter list includes x and y
    sum_result = x + y    # arguments used here inside the function
    return sum_result

some_function(25, 100)    # Arguments passed in are 25 and 100

In your function, the parameter request is listed in the parameter heading of the function but is not used inside the function. If your function has no need for this parameter, then remove it from the function header definition.

As a side note, when they’re part of the function definition, they’re referred to as parameters. When the function is being called and you’re passing in actual values, they’re referred to as arguments.

Just an fyi.


I have to use screen capture to explain what is happening.

By hovering extensively over the word ‘Render’ I got the screen capture below.

It seems to be saying that it is not able to import ‘render’.


No it is not. It is stating that you have basically imported render, but nowhere in your module is it being used. Much like the parameter request in the function members.

I am including a screen capture from w3schools Tutorial.

The instructions are a bit broken, maybe I am misunderstanding the instructions.


You should not expect a result from this code, because it only defines a function. There is more code needed in order to tell Django to use this function for responding to a web request; and then you actually need to set up the server, and make a web request to it.

This doesn’t tell us any more useful. But this is the part you should copy and paste as text (instead of an image) to explain a problem with the code.

Yes, this part cannot be copied and pasted. But it is also not a Python error. It is only PyCharm trying to warn you about a problem. Sometimes PyCharm is wrong, or it’s right in a way that doesn’t matter. What matters is what happens when you run the code.

No, like Paul already explained. “Unused” means that there is no code in the file that cares about this import. You only need this render function if you are using a template. You don’t need it for return HttpResponse("Hello world!"), because that is just sending some plain text back to the user’s web browser.

If you are having trouble with these kinds of issues, I strongly recommend that you spend more time learning to write command-line programs first, then take some time to get familiar with PyCharm, and only then think about trying to make a web app. In between, you will also need to understand some ideas about how the Internet works, and about how a web server works.

I am following the w3schools tutorial.
Is there a recommended tutorial for learning command line Python development?


There are many possibilities. The Python documentation has one built-in, but it won’t teach fundamental debugging skills - it’s designed to show off the Python language specifically, especially for people coming from other programming languages.