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

7hiiyaii  于 2023-11-21  发布在  Windows
关注(0)|答案(1)|浏览(241)

我有CygWin与Python 2和3安装。当我运行py我得到;

  1. > py
  2. launcher build: 32bit
  3. launcher executable: Console
  4. File 'C:\Users\user\AppData\Local\py.ini' non-existent
  5. File 'C:\WINDOWS\py.ini' non-existent
  6. Called with command line:
  7. locating Pythons in 64bit registry
  8. HKCU\SOFTWARE\Python\PythonCore\2.7\InstallPath: The system cannot find the file specified.
  9. HKLM\SOFTWARE\Python\PythonCore\3.4\InstallPath: The system cannot find the file specified.
  10. locating Pythons in native registry
  11. HKCU\SOFTWARE\Python\PythonCore\2.7\InstallPath: The system cannot find the file specified.
  12. locate_pythons_for_key: unable to open PythonCore key in HKLM
  13. found no configured value for 'python'
  14. search for default Python found no interpreter
  15. Can't find a default Python.

字符串
如果我创建了一个py.ini,我会在里面放什么?PEP 397在这一点上有点模糊。
另外,Windows Python Launcher似乎无法正确响应py -hpy --help。是否有关于其命令行参数的描述?
我可以从Powershell提示符运行CygWin pythonpython3,所以路径似乎是正确的。

  1. PS C:\Users\user> which python
  2. /usr/bin/python
  3. PS C:\Users\user> which python3.8
  4. /usr/bin/python3.8


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

erhoui1w

erhoui1w1#

在Win 10上创建“C:\Users\Doug\AppData\Local\py.ini”,例如

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

字符串
在当前目录下创建一个测试文件,例如“test_cygpy2”,

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


运行它,

  1. > py test_cygpy2.py


我尝试使用-i选项。这很有效:

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

展开查看全部

相关问题