close

How to fix “Can’t find a default Python” error

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How to fix “Can’t find a default Python” error in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How to fix “Can’t find a default Python” error?

  1. How to fix “Can't find a default Python” error?

    There are two problems with bypassing python launcher. Firstly the problem could return if a new version is added, and secondly the ability for programs to specify the correct python version is disabled.

  2. fix “Can't find a default Python” error

    There are two problems with bypassing python launcher. Firstly the problem could return if a new version is added, and secondly the ability for programs to specify the correct python version is disabled.

Method 1

I found the solution:

setting global variable in cmd as below resolved the issue

C:> ftype Python=”C:\Users\user x\AppData\Local\Programs\Python\Python36\python.exe %1 %*”

Method 2


‘Can’t find a default Python’ is not from windows itself, but from the python launcher.

Resetting ftype (as in some other responses) directly to a specific python install should mask the error, but is bypassing the Python Launcher. The alternative is to fix actual problem. Perhaps more complex than simply making it go away, but masking it means a key feature, python launcher, has then been disabled.

If you have this error, check ftype by entering

 ftype Python.File

without setting a new value.

The normal value should be Python.File="C:\windows\py.exe" "%L" %*

Py.exe is the Python launcher. This launcher inspects python files and for the “shebang” line at the top of the file specifying which version of python will be used.

Py.exe is the program reporting ‘cannot find a default python’. Resetting the ftype to directly load python will bypass the error, but will disables the intermediate step of py.exe which should select the correct python version for the file. If you a fine disabling py.exe, that is ok, but if you wish to fix py.exe, then try setting the environment variable PYLAUNCH_DEBUG like this (as the original poster had done):

set PYLAUNCH_DEBUG=1

Then trying again (or just enter py as a command) for more info on exactly what is failing.

For me the registry entry for

Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Python\PythonCore\3.7\InstallPath

was missing and adding that key fixed the problem. You can edit the registry keys and set the one above for the relevant python version with required path, or add a py.ini file. Instruction for the py.ini are a little long for here, but i will add a link if anyone wants.

There are two problems with bypassing python launcher. Firstly the problem could return if a new version is added, and secondly the ability for programs to specify the correct python version is disabled.

Summery

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read