Multiple Python versions on Windows

Hi πŸ‘‹

In this short article I will show you two ways of changing Python versions on Windows. It is useful when you have installed multiple Python versions on your system and want to run a specific version from the terminal.

For example, if we have the following versions installed:

We can use either the Python Launcher py to run Python or the python command.

Python Launcher

To list installed Python versions with Python launcher we can use the py -0 command.

@nutiu ➜ ~ py -0
Installed Pythons found by C:\WINDOWS\py.exe Launcher for Windows
 -3.10-64 *
 -3.7-64

@nutiu ➜ ~ py
Python 3.10.3 (tags/v3.10.3:a342a49, Mar 16 2022, 13:07:40) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

The default version has a star next to it. If we run a simple py command, we’ll get a prompt to Python 3.10. To change the default version all we need to do is to set the environment variable PY_PYTHON to the desired version.

@nutiu ➜ ~ $env:PY_PYTHON = "3.7"
@nutiu ➜ ~ py -0
Installed Pythons found by C:\WINDOWS\py.exe Launcher for Windows
 -3.10-64
 -3.7-64 *
@nutiu ➜ ~ py
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

Using the Python command

If you prefer running Python using the full command then you’ll get the Python version which has higher precedence in your path, for example if I run python on my machine I will get:

@nutiu ➜ ~ python
Python 3.10.3 (tags/v3.10.3:a342a49, Mar 16 2022, 13:07:40) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

We can change the order by going to: My PC -> Advanced System Settings -> Environment Variables

Select path from User variables and click Edit…

Python 3.10 has higher precedence in path because it is above Python 3.7. If we want to change the order, we need to select the folders referencing Python37 and click Move Up until they are above Python 3.10

Restarting your terminal and running python again should run your desired Python version.

Thanks for reading! 🍻

πŸ’»Remote Desktop: logon attempt failed β›”

Hi πŸ‘‹

Have you ever tried to setup your Windows’s Remote Desktop functionality and failed with the following error message “logon attempt failed“, knowing that your credentials were correct and that you’re on the same Wi-Fi network with the computer you’re trying to access?

Well, I did.

Most of the solutions you’ll find on other blogs make you edit your Window’s registry, network settings and so on, which in my case was not needed, and it is somehow overkill.

Logging in with a password and my Microsoft account on the computer I wanted to setup Remote Desktop solved the issue.

What I had to do was to go in Settings > Accounts > Sign-in Options, disable Windows Hello PIN and all other sign in options, setup Password sign-in option and then relog on my PC.

That’s it.

Windows 11

If you’re on Windows 11 then you don’t have sign in with a password as an option. What worked for me is to reset my PIN using my Microsoft account during the login screen.

After resetting my PIN the Remote Desktop started working.

Running Linux GUI Applications in Windows

Hi πŸ‘‹,

This is a quick tutorial on how to run Linux graphical interface application in Windows using X Server’s forwarding feature.

The first step is to download and install the VcXsrv Windows X Server on your πŸ’» Windows machine.

Then, start VcXsrv with the following configuration:

Ensure that VcXsrv is not blocked in Windows Firewall, it should be allowed in Public and Private networks.

You may also use more restrictive firewal settings as explained in /wsl-windows-toolbar-launcher#firewall-rules.


The next step is to configure your Linux box.

I’m using Ubuntu in WSL 2.0 and pasting the following code into ~/.zshrc or ~/.bashrc does the trick for me. Feel free to upvote the author on SO.

# X11
HOST_IP=$(host `hostname` | grep -oP '(\s)\d+(\.\d+){3}' | tail -1 | awk '{ print $NF }' | tr -d '\r')
export LIBGL_ALWAYS_INDIRECT=1
export DISPLAY=$HOST_IP:0.0
export NO_AT_BRIDGE=1
export PULSE_SERVER=tcp:$HOST_IP

After that’s done, if VcXsrv is running, you should be able to open Linux GUI apps from your Terminal.

Thanks for reading! 🍺

How to use Windows 10’s Wireless Display feature

Hi,

In this article I will show you how to use your Windows 10’s wireless display feature in order to use your Laptop/Xbox as a wireless display.

Initial Setup

First things first let’s enable network discoverability on both PCs. Open up Control Panel, go to Network and Internet, next Network and Sharing Center and click on Change advanced sharing settings

Then expand the Private tab and use the same settings as I do, only enable File sharing if you need it.

Turning on file and printer sharing is optional.

Now that this is done we want to mark our house’s Wi-Fi network as Private, this way Windows will trust it and network discovery will be enabled.

Note: When connecting to public networks it’s a good idea to mark them as public and have network discovery off, attackers may use this feature for malicious purposes.

To mark your network as Private type Network Status in the search box, click Properties and make sure that Private is selected.

That’s it! πŸŽ‰πŸŽ‰

Projecting to this PC

Open up search and type Projection Settings, you’ll notice a message prompting you to install the Wireless Display optional Windows feature, click that link and type “Display” then install it.

You can leave the settings as they are, it means that your devices can only project when you open the Connect application on your PC or the Wireless Display application on your Xbox.

Click Launch the Connect app… on your Laptop to start projecting from your PC.

Your laptop should now appear as a Wireless Display when trying to Project from a PC on the same network.

Bonus: Xbox

You can project from your Windows computers on your Xbox by installing the Wireless Display application and launching it. The devices should be connected on the same network and network discovery should be on.

That’s it, thanks for reading!

If you want me to write about something, let me know! πŸ™‚