#37452 closed Cleanup/optimization (fixed)
Add PowerShell instructions in Windows How To
| Reported by: | Jonathan Biemond | Owned by: | Shabir Ahmad Shaik |
|---|---|---|---|
| Component: | Documentation | Version: | 6.1 |
| Severity: | Normal | Keywords: | |
| Cc: | Triage Stage: | Accepted | |
| Has patch: | yes | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | yes | UI/UX: | no |
Description
Currently the How To for installing Django on Windows includes an instruction to activate the virtual environment with the batch script.
...\> project-name\Scripts\activate.bat
https://docs.djangoproject.com/en/6.1/howto/windows/#setting-up-a-virtual-environment
Many Windows users are likely to be using PowerShell, and instead they need to use:
...\> project-name\Scripts\activate.ps1
Let's update the tutorial to include the instructions for PowerShell.
Change History (13)
comment:1 by , 3 weeks ago
| Owner: | changed from to |
|---|
comment:2 by , 3 weeks ago
comment:3 by , 3 weeks ago
Hi! I'd like to contribute a fix for this issue by adding the PowerShell activation instructions alongside the existing Command Prompt example in docs/howto/windows.txt.
I noticed the ticket is currently assigned to someone else. Is this issue still being worked on, or would it be possible for me to take it on and submit a patch?
comment:4 by , 3 weeks ago
Atharv jadon, there are plenty of other tickets to work on without asking about tickets that have not yet been accepted. What would be quite useful at this time would be to review a patch from one of the items in the review queue -- see "Needs PR Review".
follow-up: 8 comment:5 by , 3 weeks ago
| Triage Stage: | Unreviewed → Accepted |
|---|
I agree with updating the docs to support use of more modern terminals in Windows.
Rather than adding two examples I think we could use a plain activate (no extension) which should work across both cmd and powershell.
...\> project-name\Scripts\activate
This is what is used in Python's virtual environment tutorial. There was also some discussion about this on the cPython issue tracker which had this comment:
Running tutorial-env\Scripts\activate should suffice. The .bat script is for CMD, and the .ps1 script is for PowerShell. The shell should run the right script without having to include the extension.
I think the fix for this ticket should audit for all uses of examples using cmd. For example the Writing your first contribution for Django docs also have an example using the .bat version to activate the virtual environment.
comment:6 by , 3 weeks ago
| Version: | dev → 6.1 |
|---|
comment:7 by , 3 weeks ago
Jonathan - I agree with your thinking about a separate ticket for the execution policy. I'm happy to triage such as ticket as I ran into this issue today.
I ended up following the guidance in the Python docs at https://docs.python.org/3/library/venv.html?#creating-virtual-environments.
PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
comment:8 by , 3 weeks ago
Replying to David Smith:
I agree with updating the docs to support use of more modern terminals in Windows.
Rather than adding two examples I think we could use a plain
activate(no extension) which should work across bothcmdandpowershell.
...\> project-name\Scripts\activateThis is what is used in Python's virtual environment tutorial. There was also some discussion about this on the cPython issue tracker which had this comment:
Running tutorial-env\Scripts\activate should suffice. The .bat script is for CMD, and the .ps1 script is for PowerShell. The shell should run the right script without having to include the extension.
I think the fix for this ticket should audit for all uses of examples using
cmd. For example the Writing your first contribution for Django docs also have an example using the.batversion to activate the virtual environment.
Hey David Can I have your name and email to mention you as Co-author in commit if that's ok ? I don't know if it is right place to ask so apologies beforehand if I did something wrong.
(Edit) My apologies I didn't know Co-Authored-By is when I build on other's(co-author's) work or use their work in my commit. I wanted to share credit but after re-reading I figured out this isn't the right way.
comment:9 by , 3 weeks ago
| Has patch: | set |
|---|
comment:10 by , 3 weeks ago
Hi David Smith and Shabir Ahmad Shaik, I've created ticket #37462 for execution policy instructions. Please feel free to set yourself as the owner, if you are interested in writing up a PR. Otherwise I will free it up.
comment:11 by , 2 weeks ago
Aside: If it would be helpful in the documentation, I think it might be quite feasible to add a third "PowerShell" tab to Django's .. console:: directive. (Having just spent a lot of time in that part of the djangodocs Sphinx extension.) Just mentioning it as a possibility here; we should open a separate ticket if there's interest.
It's worth noting that the next error PowerShell users are likely to run into is being blocked by the Execution Policy.
I think this is worth a separate ticket (pending this one's acceptance). Some prior discussion on the forum: https://forum.djangoproject.com/t/virtual-environment-on-windows/8445