# Path Problem Path Problem

**URL:** <https://discuss.python.org/t/path-problem-path-problem/44375>\
**Category:** Python Help\
**Created:** [January 28, 2024, 2:26pm UTC](https://discuss.python.org/t/path-problem-path-problem/44375 "2024-01-28T14:26:33Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![MikeSmith](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@MikeSmith](https://discuss.python.org/u/MikeSmith)\
**Post date:** [January 28, 2024, 2:26pm UTC](https://discuss.python.org/t/path-problem-path-problem/44375/1 "2024-01-28T14:26:33Z")

</div>

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.

Mike

 ![PrintScreen07](https://us1.discourse-cdn.com/flex002/uploads/python1/original/3X/f/4/f4e95c4d9ac75cf8ba98345fa1f9bc9046060764.jpeg)

---

<div class="post-metadata">

**Author:** ![onePythonUser](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/onepythonuser/32/19158_2.png) [@onePythonUser](https://discuss.python.org/u/onePythonUser)\
**Post date:** [January 28, 2024, 3:05pm UTC](https://discuss.python.org/t/path-problem-path-problem/44375/2 "2024-01-28T15:05:28Z")

</div>

Hi,

at the Python prompt, try this for test purposes:

```python
import os
os.getcwd()

```

What do you get?

Remember that you can always check your PYTHONPATH via:

```python
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):')
    print('-'*91)
    
    for path in PATHS:
        print('{}. {}'.format(num, path))
        num += 1
        
get_my_python_path()

```

---

<div class="post-metadata">

**Author:** ![kknechtel](https://avatars.discourse-cdn.com/v4/letter/k/e47c2d/32.png) [@kknechtel](https://discuss.python.org/u/kknechtel)\
**Post date:** [January 28, 2024, 3:35pm UTC](https://discuss.python.org/t/path-problem-path-problem/44375/3 "2024-01-28T15:35:59Z")

</div>

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:

> [@Could we add Python to system PATH by default?](https://discuss.python.org/t/could-we-add-python-to-system-path-by-default/3067):
>
> When installing python for Windows, I see a checkbox that gives an option of adding it to the ‘PATH’ which I presume is adding it to system environment variables. Given that majority of users installing Python want it to be added to the PATH so that it can be called from the terminal and IDEs. I have been working with analysts learning python for data and it caused issues to almost all of them. Could we move to have this option selected by default?

And some other resources:

> <https://stackoverflow.com/questions/34900042/why-would-i-add-python-to-path>

[https://www.reddit.com/r/Python/comments/2vuhiw](https://www.reddit.com/r/Python/comments/2vuhiw)

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:

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

```

---

<div class="post-metadata">

**Author:** ![MikeSmith](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@MikeSmith](https://discuss.python.org/u/MikeSmith)\
**Post date:** [January 29, 2024, 1:26am UTC](https://discuss.python.org/t/path-problem-path-problem/44375/4 "2024-01-29T01:26:43Z")

</div>

Karl:

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.

Mike

---

<div class="post-metadata">

**Author:** ![MikeSmith](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@MikeSmith](https://discuss.python.org/u/MikeSmith)\
**Post date:** [January 29, 2024, 4:47am UTC](https://discuss.python.org/t/path-problem-path-problem/44375/5 "2024-01-29T04:47:51Z")

</div>

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

 ![PrintScreen10](https://us1.discourse-cdn.com/flex002/uploads/python1/original/3X/7/9/7970551c4b2202d309889d5cd8e4c548c5662a20.jpeg)

---

<div class="post-metadata">

**Author:** ![onePythonUser](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/onepythonuser/32/19158_2.png) [@onePythonUser](https://discuss.python.org/u/onePythonUser)\
**Post date:** [January 29, 2024, 1:33pm UTC](https://discuss.python.org/t/path-problem-path-problem/44375/6 "2024-01-29T13:33:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![MikeSmith](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@MikeSmith](https://discuss.python.org/u/MikeSmith)\
**Post date:** [January 29, 2024, 8:02pm UTC](https://discuss.python.org/t/path-problem-path-problem/44375/7 "2024-01-29T20:02:05Z")

</div>

Paul:

I have run this code in PyCharm:

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

Mike

 ![PrintScreen11](https://us1.discourse-cdn.com/flex002/uploads/python1/original/3X/b/a/ba3c4bf463f047dd8f2228fc3ea47d9423de440b.jpeg)

---

<div class="post-metadata">

**Author:** ![cameron](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/cameron/32/2658_2.png) [@cameron](https://discuss.python.org/u/cameron)\
**Post date:** [January 29, 2024, 8:19pm UTC](https://discuss.python.org/t/path-problem-path-problem/44375/8 "2024-01-29T20:19:52Z")

</div>

> I have run this code in PyCharm:
> 
> ```python
> 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.

---

<div class="post-metadata">

**Author:** ![onePythonUser](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/onepythonuser/32/19158_2.png) [@onePythonUser](https://discuss.python.org/u/onePythonUser)\
**Post date:** [January 29, 2024, 9:26pm UTC](https://discuss.python.org/t/path-problem-path-problem/44375/9 "2024-01-29T21:26:05Z")

</div>

> [@MikeSmith](#):
>
> I get an Exit Code of 0 which I think is good but there is no result.

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,

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

---

<div class="post-metadata">

**Author:** ![MikeSmith](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@MikeSmith](https://discuss.python.org/u/MikeSmith)\
**Post date:** [January 29, 2024, 10:05pm UTC](https://discuss.python.org/t/path-problem-path-problem/44375/10 "2024-01-29T22:05:30Z")

</div>

Cameron:

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

Mike

 ![PrintScreen12](https://us1.discourse-cdn.com/flex002/uploads/python1/original/3X/d/9/d937ee8f8bd55996d2d35071ececa3f6201b571e.jpeg)

---

<div class="post-metadata">

**Author:** ![onePythonUser](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/onepythonuser/32/19158_2.png) [@onePythonUser](https://discuss.python.org/u/onePythonUser)\
**Post date:** [January 29, 2024, 10:10pm UTC](https://discuss.python.org/t/path-problem-path-problem/44375/11 "2024-01-29T22:10:20Z")

</div>

> [@MikeSmith](#):
>
> 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`.

---

<div class="post-metadata">

**Author:** ![MikeSmith](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@MikeSmith](https://discuss.python.org/u/MikeSmith)\
**Post date:** [January 29, 2024, 11:15pm UTC](https://discuss.python.org/t/path-problem-path-problem/44375/12 "2024-01-29T23:15:31Z")

</div>

I am including a screen capture from w3schools Tutorial.

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

Mike

 ![PrintScreen13](https://us1.discourse-cdn.com/flex002/uploads/python1/original/3X/4/f/4f38307089ae28f58134efc5b741f85b13228383.jpeg)

---

<div class="post-metadata">

**Author:** ![kknechtel](https://avatars.discourse-cdn.com/v4/letter/k/e47c2d/32.png) [@kknechtel](https://discuss.python.org/u/kknechtel)\
**Post date:** [January 29, 2024, 11:24pm UTC](https://discuss.python.org/t/path-problem-path-problem/44375/13 "2024-01-29T23:24:18Z")

</div>

> [@MikeSmith](#):
>
> I get an Exit Code of 0 which I think is good but there is no result.

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.

> [@MikeSmith](#):
>
> See screen capture below.

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.

> [@MikeSmith](#):
>
> By hovering extensively over the word ‘Render’ I got the screen capture below.

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.

> [@MikeSmith](#):
>
> It seems to be saying that it is not able to import ‘render’.

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.

---

<div class="post-metadata">

**Author:** ![MikeSmith](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@MikeSmith](https://discuss.python.org/u/MikeSmith)\
**Post date:** [January 29, 2024, 11:58pm UTC](https://discuss.python.org/t/path-problem-path-problem/44375/14 "2024-01-29T23:58:21Z")

</div>

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

Mike

---

<div class="post-metadata">

**Author:** ![kknechtel](https://avatars.discourse-cdn.com/v4/letter/k/e47c2d/32.png) [@kknechtel](https://discuss.python.org/u/kknechtel)\
**Post date:** [January 30, 2024, 1:49am UTC](https://discuss.python.org/t/path-problem-path-problem/44375/15 "2024-01-30T01:49:01Z")

</div>

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.
