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

夙愿已清 提交于 2020-02-07 02:55:10

问题


I am using python in a windows server(64 bit) and it is installed by another user in his own directory in C:\user\userx\AppData\Local\Programs\Python\Python36

All other users (excluding me) are able to run Python files on this server. I get the following error when I run a Python programm:

C:\Users\user x\AppData\Local\Programs\Python\Python36>test.py
launcher build: 32bit
launcher executable: Console
File 'C:\Users\my user\AppData\Local\py.ini' non-existent
File 'C:\Windows\py.ini' non-existent
Called with command line: "C:\Users\user x\AppData\Local\Programs\Python\Python
36\test.py"
maybe_handle_shebang: read 12 bytes
maybe_handle_shebang: BOM not found, using UTF-8
locating Pythons in 64bit registry
locate_pythons_for_key: unable to open PythonCore key in HKCU
locate_pythons_for_key: unable to open PythonCore key in HKLM
locating Pythons in native registry
locate_pythons_for_key: unable to open PythonCore key in HKCU
locate_pythons_for_key: unable to open PythonCore key in HKLM
found no configured value for 'python'
search for default Python found no interpreter
Can't find a default Python.

I tried running my code in the command line with set pylaunch_debug=1 and it showed below errors.


回答1:


Associate the correct file group with .py scripts:

assoc .py=Python.File

Redirect all Python files to the new executable:

ftype Python.File="C:\Path\to\pythonw.exe %1 %*"



回答2:


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 %*"



来源:https://stackoverflow.com/questions/57765741/how-to-fix-cant-find-a-default-python-error

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!