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

7hiiyaii  于 6个月前  发布在  Windows
关注(0)|答案(1)|浏览(79)

我有CygWin与Python 2和3安装。当我运行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。是否有关于其命令行参数的描述?
我可以从Powershell提示符运行CygWin pythonpython3,所以路径似乎是正确的。

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


其他的想法?也许我可以安装一个CygWin py,它可以取代Windows,并且行为正常?

erhoui1w

erhoui1w1#

在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]'
>>>

相关问题