Python已安装,但在终端中不工作

2024-05-16 03:10:06 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用Cygwin终端安装了Python 3。安装过程中没有问题。 我明白了:

$ which python3
/usr/bin/python3

$ whereis python3
python3: /usr/bin/python3 /usr/bin/python3.6 /usr/lib/python3.6 /usr/lib/python3.8 
/usr/include/python3.6m /usr/include/python3.8 /usr/share/man/man1/python3.1.gz

但两者都不是

$ python3 $ python3 main.py $ python3 --version

给出任何输出。我以前在同一台计算机上用同样的方法做过,效果很好。这次我做错了什么?还是忘了做


Tags: 终端sharewhichbinincludemain过程lib
2条回答

尝试创建一个别名,将python附加到公共名称“python3”上。在Cygwin终端中写入:

$ alias python3=$(which python3.6)

python3应该是由指向python3.8alternatives管理的链接

$ alternatives  display python3
python3 - status is auto.
 link currently points to /usr/bin/python3.8
/usr/bin/python3.6 - priority 36
/usr/bin/python3.7 - priority 37
/usr/bin/python3.8 - priority 38
Current `best' version is /usr/bin/python3.8.

属于python38包的

$ cygcheck -f /usr/bin/python3.8
python38-3.8.7-3

验证python38是否已正确安装

$ cygcheck -c python38
Cygwin Package Information
Package              Version        Status
python38             3.8.7-3        OK

而且依赖性没有问题

$ cygcheck /usr/bin/python3.8.exe
D:\cygwin64\bin\python3.8.exe
  D:\cygwin64\bin\cygwin1.dll
    C:\WINDOWS\system32\KERNEL32.dll
      C:\WINDOWS\system32\ntdll.dll
      C:\WINDOWS\system32\KERNELBASE.dll
  D:\cygwin64\bin\libpython3.8.dll
    D:\cygwin64\bin\cygintl-8.dll
      D:\cygwin64\bin\cygiconv-2.dll
    D:\cygwin64\bin\cyggcc_s-seh-1.dll

更有可能需要重新安装python38或所需的库之一

$ cygcheck -f /usr/bin/cygwin1.dll /usr/bin/cygintl-8.dll /usr/bin/cygiconv-2.dll  /usr/bin/cyggcc_s-seh-1.dll
cygwin-3.1.7-1
libgcc1-10.2.0-1
libiconv2-1.16-2
libintl8-0.19.8.1-2

确保在重新安装软件包之前停止allCygwinprocesses;特别是任何运行服务

相关问题 更多 >