环境问题,隔段时间或者因此系统清理等原因,Python的环境就遭到破坏,提示以下问题
PS D:\> scons
scons : 无法将“scons”项识别为 cmdlet、函数、脚本文件或可运行程序的名称。请检查名称的拼写,如果包括路径,请确保路径正确,然后再试一次。
所在位置 行:1 字符: 1
+ scons
+ ~~~~~
+ CategoryInfo : ObjectNotFound: (scons:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS D:\> python -V
Python 3.7.0
PS D:\> python -m pip list
D:\Users\Thinkpad\AppData\Local\Programs\Python\Python39\python.exe: No module named pip
本地的Python安装目录已经被清理了。
修复过程:
1、windows修复Python,在appwiz.cpl中,找到Python,更改
> Repair
修复Python
此时D:\Users\Thinkpad\AppData\Local\Programs\Python
又回来了。
2、修复pip模块,重新安装scons
PS D:\> python -m ensurepip
Looking in links: c:\Users\Thinkpad\AppData\Local\Temp\tmpjk0von5f
Processing c:\users\thinkpad\appdata\local\temp\tmpjk0von5f\setuptools-58.1.0-py3-none-any.whl
Processing c:\users\thinkpad\appdata\local\temp\tmpjk0von5f\pip-22.0.4-py3-none-any.whl
Installing collected packages: setuptools, pip
Successfully installed pip-22.0.4 setuptools-58.1.0
PS D:\> python -m pip list
Package Version
---------- -------
pip 22.0.4
setuptools 58.1.0
WARNING: You are using pip version 22.0.4; however, version 22.3.1 is available.
You should consider upgrading via the 'D:\Users\Thinkpad\AppData\Local\Programs\Python\Python39\python.exe -m pip install --upgrade pip' command.
PS D:\> D:\Users\Thinkpad\AppData\Local\Programs\Python\Python39\python.exe -m pip install --upgrade pip
Requirement already satisfied: pip in d:\users\thinkpad\appdata\local\programs\python\python39\lib\site-packages (22.0.4)
Collecting pip
Using cached pip-22.3.1-py3-none-any.whl (2.1 MB)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 22.0.4
Uninstalling pip-22.0.4:
Successfully uninstalled pip-22.0.4
Successfully installed pip-22.3.1
PS D:\>
PS D:\> python -m pip install scons
Collecting scons
Using cached SCons-4.4.0-py3-none-any.whl (4.2 MB)
Requirement already satisfied: setuptools in d:\users\thinkpad\appdata\local\programs\python\python39\lib\site-packages (from scons) (58.1.0)
Installing collected packages: scons
Successfully installed scons-4.4.0
PS D:\> scons
scons: *** No SConstruct file found.