From e9aba1ee6d86b0e22c906b8924b1a71297ed727d Mon Sep 17 00:00:00 2001 From: Aleksandra Nenadic Date: Thu, 9 Nov 2023 11:37:26 +0000 Subject: [PATCH 1/2] Added a note on python hanging issue on Windows --- _episodes/12-virtual-environments.md | 11 +++++++++++ _extras/common-issues.md | 14 ++++++++++++-- setup.md | 4 ++++ 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/_episodes/12-virtual-environments.md b/_episodes/12-virtual-environments.md index 2554d696c..94fb31640 100644 --- a/_episodes/12-virtual-environments.md +++ b/_episodes/12-virtual-environments.md @@ -196,6 +196,17 @@ From XKCD (Creative Commons Let us have a look at how we can create and manage virtual environments from the command line using `venv` and manage packages using `pip`. +> ## Making Sure You Can Invoke Python +> You can test your Python installation from the command line with: +> ~~~ +> $ python3 --version # on Mac/Linux +> $ python --version # on Windows — Windows installation comes with a python.exe file rather than a python3.exe file +> ~~~ +> {: .language-bash} +> If you are using Windows and invoking `python` command causes your Git Bash terminal to hang with no error message or output, you may +need to create an alias for the python executable `python.exe`, as explained in the [troubleshooting section](../common-issues/index.html#python-hangs-in-git-bash). +{: .callout} + ### Creating Virtual Environments Using `venv` Creating a virtual environment with `venv` is done by executing the following command: diff --git a/_extras/common-issues.md b/_extras/common-issues.md index 82ebe7817..1bc208b5f 100644 --- a/_extras/common-issues.md +++ b/_extras/common-issues.md @@ -13,10 +13,20 @@ Hanging issues with trying to run Python 3 in Git Bash on Windows The solution appears to be to use `winpty` - a Windows software package providing an interface similar to a Unix pty-master for communicating with Windows command line tools. -Inside the shell type `alias python='winpty python.exe'`. +Inside the shell type: + +~~~ +$ alias python="winpty python.exe" +~~~ +{: .language-bash} + This alias will be valid for the duration of the shell session. For a more permanent solution, from the shell do: -`echo "alias python='winpty python.exe'" >> ~/.bashrc` +~~~ +$ echo "alias python='winpty python.exe'" >> ~/.bashrc +~~~ +{: .language-bash} + (and from there on remember to invoke Python as `python` or whatever command you aliased it to). Read more details on the issue at diff --git a/setup.md b/setup.md index c74c5524a..2cc49d08a 100644 --- a/setup.md +++ b/setup.md @@ -222,6 +222,10 @@ $ python3 --version # on Mac/Linux $ python --version # on Windows — Windows installation comes with a python.exe file rather than a python3.exe file ~~~ {: .language-bash} + +If you are using Windows and invoking `python` command causes your Git Bash terminal to hang with no error message or output, you may +need to create an alias for the python executable `python.exe`, as explained in the [troubleshooting section](../common-issues/index.html#python-hangs-in-git-bash). + If all is well with your installation, you should see something like: ~~~ Python 3.8.2 From 8dedd54a74d54eef046936fe9f0c2b1c0ebaa2cd Mon Sep 17 00:00:00 2001 From: Aleksandra Nenadic Date: Mon, 20 Nov 2023 10:39:35 +0000 Subject: [PATCH 2/2] Update _episodes/12-virtual-environments.md --- _episodes/12-virtual-environments.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_episodes/12-virtual-environments.md b/_episodes/12-virtual-environments.md index 94fb31640..4b81e5c69 100644 --- a/_episodes/12-virtual-environments.md +++ b/_episodes/12-virtual-environments.md @@ -205,7 +205,7 @@ using `venv` and manage packages using `pip`. > {: .language-bash} > If you are using Windows and invoking `python` command causes your Git Bash terminal to hang with no error message or output, you may need to create an alias for the python executable `python.exe`, as explained in the [troubleshooting section](../common-issues/index.html#python-hangs-in-git-bash). -{: .callout} +{: .prereq} ### Creating Virtual Environments Using `venv` Creating a virtual environment with `venv` is done by executing the following command: