python 如何修复在Windows 10上安装psutil时出现的错误?

0yycz8jy  于 2023-02-07  发布在  Python
关注(0)|答案(2)|浏览(278)

每次我尝试通过“pip install psutil”命令在python的命令提示符中安装psutil时,它都会给我以下错误消息:

Complete output (38 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win32-3.10
    creating build\lib.win32-3.10\psutil
    copying psutil\_common.py -> build\lib.win32-3.10\psutil
    copying psutil\_compat.py -> build\lib.win32-3.10\psutil
    copying psutil\_psaix.py -> build\lib.win32-3.10\psutil
    copying psutil\_psbsd.py -> build\lib.win32-3.10\psutil
    copying psutil\_pslinux.py -> build\lib.win32-3.10\psutil
    copying psutil\_psosx.py -> build\lib.win32-3.10\psutil
    copying psutil\_psposix.py -> build\lib.win32-3.10\psutil
    copying psutil\_pssunos.py -> build\lib.win32-3.10\psutil
    copying psutil\_pswindows.py -> build\lib.win32-3.10\psutil
    copying psutil\__init__.py -> build\lib.win32-3.10\psutil
    creating build\lib.win32-3.10\psutil\tests
    copying psutil\tests\runner.py -> build\lib.win32-3.10\psutil\tests
    copying psutil\tests\test_aix.py -> build\lib.win32-3.10\psutil\tests
    copying psutil\tests\test_bsd.py -> build\lib.win32-3.10\psutil\tests
    copying psutil\tests\test_connections.py -> build\lib.win32-3.10\psutil\tests
    copying psutil\tests\test_contracts.py -> build\lib.win32-3.10\psutil\tests
    copying psutil\tests\test_linux.py -> build\lib.win32-3.10\psutil\tests
    copying psutil\tests\test_memleaks.py -> build\lib.win32-3.10\psutil\tests
    copying psutil\tests\test_misc.py -> build\lib.win32-3.10\psutil\tests
    copying psutil\tests\test_osx.py -> build\lib.win32-3.10\psutil\tests
    copying psutil\tests\test_posix.py -> build\lib.win32-3.10\psutil\tests
    copying psutil\tests\test_process.py -> build\lib.win32-3.10\psutil\tests
    copying psutil\tests\test_sunos.py -> build\lib.win32-3.10\psutil\tests
    copying psutil\tests\test_system.py -> build\lib.win32-3.10\psutil\tests
    copying psutil\tests\test_testutils.py -> build\lib.win32-3.10\psutil\tests
    copying psutil\tests\test_unicode.py -> build\lib.win32-3.10\psutil\tests
    copying psutil\tests\test_windows.py -> build\lib.win32-3.10\psutil\tests
    copying psutil\tests\__init__.py -> build\lib.win32-3.10\psutil\tests
    copying psutil\tests\__main__.py -> build\lib.win32-3.10\psutil\tests
    running build_ext
    building 'psutil._psutil_windows' extension
    error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\windows 10 pro\AppData\Local\Programs\Python\Python310-32\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\windows 10 pro\\AppData\\Local\\Temp\\pip-install-freyn2_2\\psutil_d40b23d5499d4943a851ba2d31c42b65\\setup.py'"'"'; __file__='"'"'C:\\Users\\windows 10 pro\\AppData\\Local\\Temp\\pip-install-freyn2_2\\psutil_d40b23d5499d4943a851ba2d31c42b65\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\windows 10 pro\AppData\Local\Temp\pip-record-8dc_d_jb\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\windows 10 pro\AppData\Local\Programs\Python\Python310-32\Include\psutil' Check the logs for full command output.

有人能帮我吗?这样我就可以编辑和运行.py文件了

d7v8vwbk

d7v8vwbk1#

您可以继续使用版本5.9.3来避免此错误

pip install psutil==5.9.3

参见此处:https://github.com/giampaolo/psutil/issues/2165

42fyovps

42fyovps2#

正如错误日志中提到的,您需要从提供给您的链接安装编译器,因为您试图安装的包需要一个编译器,因为您访问Win32 API(一个C/C库)的方式使用了C/C/Cython或其他编译代码,即Python扩展,不像其他纯Python包,只需要一个特定的Python版本,实现或位。
https://visualstudio.microsoft.com/visual-cpp-build-tools/

相关问题