如何让Windows Python Launcher识别Cygwin Python 2 & 3?

问题描述 投票:0回答:1

我有安装了Python 2 & 3的CygWin。 当我运行 py 我明白了。

> py
launcher build: 32bit
launcher executable: Console
File 'C:\Users\user\AppData\Local\py.ini' non-existent
File 'C:\WINDOWS\py.ini' non-existent
Called with command line:
locating Pythons in 64bit registry
HKCU\SOFTWARE\Python\PythonCore\2.7\InstallPath: The system cannot find the file specified.
HKLM\SOFTWARE\Python\PythonCore\3.4\InstallPath: The system cannot find the file specified.
locating Pythons in native registry
HKCU\SOFTWARE\Python\PythonCore\2.7\InstallPath: The system cannot find the file specified.
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.

如果我创建一个 py.ini我在里面放什么? PEP 397 在这一点上是有点模糊的。

另外,Windows Python Launcher 似乎不能正确地响应于 py -hpy --help. 有关于它的命令行参数的描述吗?

我可以运行CygWin pythonpython3 来自Powershell提示,所以路径似乎是正确的。

PS C:\Users\user> which python
/usr/bin/python
PS C:\Users\user> which python3.8
/usr/bin/python3.8

其他的想法? 也许我可以安装一个CygWin py 会超越 Windows 的,并且表现得很理智?

python windows cygwin
1个回答
0
投票

在Win 10上创建 "C:\Users\Doug\AppData\Local\py.ini",并使用如。

[commands]
cygpy2=C:\cygwin64\bin\python2.7.exe

在当前目录下创建一个测试文件,例如 "test_cygpy2",并在其中加入

#! cygpy2
import sys
print 'Hello, python', sys.version

并运行为

> py test_cygpy2.py

我尝试使用-i选项。这样就可以了。

> py -i test_cygpy2.py
Hello, python 2.7.16 (default, Mar 20 2019, 12:15:19)
[GCC 7.4.0]
>>> import sys
>>> sys.version
'2.7.16 (default, Mar 20 2019, 12:15:19) \n[GCC 7.4.0]'
>>>

HTH

© www.soinside.com 2019 - 2024. All rights reserved.