RuntimeError:由于Windows运行时中的错误,当前的Numpy安装未能通过完整性检查[重复]

Posted

技术标签:

【中文标题】RuntimeError:由于Windows运行时中的错误,当前的Numpy安装未能通过完整性检查[重复]【英文标题】:RuntimeError: The current Numpy installation fails to pass a sanity check due to a bug in the windows runtime [duplicate] 【发布时间】:2021-02-20 02:12:02 【问题描述】:

我在 Windows 10 版本 2004 x64 上使用 Python 3.9。 PowerShell 作为管理员。

Python 版本:

Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32

安装matplotlib错误。

pip install virtualenv
virtualenv foo
cd .\foo
.\Scripts\active
pip install numpy
pip install matplotlib

错误

Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS C:\WINDOWS\system32> Set-ExecutionPolicy Unrestricted -Force
PS C:\WINDOWS\system32> cd /d C:\Windows\System32\cmd.exe
Set-Location : A positional parameter cannot be found that accepts argument 'C:\Windows\System32\cmd.exe'.
At line:1 char:1
+ cd /d C:\Windows\System32\cmd.exe
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Set-Location], ParameterBindingException
    + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.SetLocationCommand

PS C:\WINDOWS\system32> cd C:\Windows\System32\cmd.exe
cd : Cannot find path 'C:\Windows\System32\cmd.exe' because it does not exist.
At line:1 char:1
+ cd C:\Windows\System32\cmd.exe
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Windows\System32\cmd.exe:String) [Set-Location], ItemNotFoundExcepti
   on
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.SetLocationCommand

PS C:\WINDOWS\system32> cd D:\
PS D:\> cd .\Users\donhuvy\
PS D:\Users\donhuvy> ls


    Directory: D:\Users\donhuvy


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        10/26/2020   3:35 PM                AppData
d-----         11/7/2020   9:33 AM                PycharmProjects


PS D:\Users\donhuvy> cd .\PycharmProjects\pythonProject\
PS D:\Users\donhuvy\PycharmProjects\pythonProject> virtualenv foo
virtualenv : The term 'virtualenv' is not recognized as the name of a cmdlet, function, script file, or operable
program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ virtualenv foo
+ ~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (virtualenv:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS D:\Users\donhuvy\PycharmProjects\pythonProject> pip install virtualenv
Collecting virtualenv
  Downloading virtualenv-20.1.0-py2.py3-none-any.whl (4.9 MB)
     |████████████████████████████████| 4.9 MB 1.1 MB/s
Collecting distlib<1,>=0.3.1
  Downloading distlib-0.3.1-py2.py3-none-any.whl (335 kB)
     |████████████████████████████████| 335 kB 6.4 MB/s
Requirement already satisfied: six<2,>=1.9.0 in c:\users\donhuvy\appdata\roaming\python\python39\site-packages (from virtualenv) (1.15.0)
Collecting filelock<4,>=3.0.0
  Downloading filelock-3.0.12-py3-none-any.whl (7.6 kB)
Collecting appdirs<2,>=1.4.3
  Downloading appdirs-1.4.4-py2.py3-none-any.whl (9.6 kB)
Installing collected packages: distlib, filelock, appdirs, virtualenv
Successfully installed appdirs-1.4.4 distlib-0.3.1 filelock-3.0.12 virtualenv-20.1.0
PS D:\Users\donhuvy\PycharmProjects\pythonProject> virtualenv foo
created virtual environment CPython3.9.0.final.0-64 in 1312ms
  creator CPython3Windows(dest=D:\Users\donhuvy\PycharmProjects\pythonProject\foo, clear=False, global=False)
  seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle, via=copy, app_data_dir=C:\Users\donhuvy\AppData\Local\pypa\virtualenv)
    added seed packages: pip==20.2.4, setuptools==50.3.2, wheel==0.35.1
  activators BashActivator,BatchActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
PS D:\Users\donhuvy\PycharmProjects\pythonProject> cd .\foo
PS D:\Users\donhuvy\PycharmProjects\pythonProject\foo> .\Scripts\activate
(foo) PS D:\Users\donhuvy\PycharmProjects\pythonProject\foo> pip install numpy
Collecting numpy
  Using cached numpy-1.19.4-cp39-cp39-win_amd64.whl (13.0 MB)
Installing collected packages: numpy
Successfully installed numpy-1.19.4
(foo) PS D:\Users\donhuvy\PycharmProjects\pythonProject\foo> pip install matplotlib
Collecting matplotlib
  Using cached matplotlib-3.3.2.tar.gz (37.9 MB)
 ** On entry to DGEBAL parameter number  3 had an illegal value
 ** On entry to DGEHRD  parameter number  2 had an illegal value
 ** On entry to DORGHR DORGQR parameter number  2 had an illegal value
 ** On entry to DHSEQR parameter number  4 had an illegal value
    ERROR: Command errored out with exit status 1:
     command: 'D:\Users\donhuvy\PycharmProjects\pythonProject\foo\Scripts\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\donhuvy\\AppData\\Local\\Temp\\pip-install-8bn40qg7\\matplotlib\\setup.py'"'"'; __file__='"'"'C:\\Users\\donhuvy\\AppData\\Local\\Temp\\pip-install-8bn40qg7\\matplotlib\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\donhuvy\AppData\Local\Temp\pip-pip-egg-info-39nmc0pe'
         cwd: C:\Users\donhuvy\AppData\Local\Temp\pip-install-8bn40qg7\matplotlib\
    Complete output (61 lines):

    Edit setup.cfg to change the build options; suppress output with --quiet.

    BUILDING MATPLOTLIB
      matplotlib: yes [3.3.2]
          python: yes [3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC
                      v.1927 64 bit (AMD64)]]
        platform: yes [win32]
     sample_data: yes [installing]
           tests: no  [skipping due to configuration]
          macosx: no  [Mac OS-X only]

    running egg_info
    creating C:\Users\donhuvy\AppData\Local\Temp\pip-pip-egg-info-39nmc0pe\matplotlib.egg-info
    writing C:\Users\donhuvy\AppData\Local\Temp\pip-pip-egg-info-39nmc0pe\matplotlib.egg-info\PKG-INFO
    writing dependency_links to C:\Users\donhuvy\AppData\Local\Temp\pip-pip-egg-info-39nmc0pe\matplotlib.egg-info\dependency_links.txt
    writing namespace_packages to C:\Users\donhuvy\AppData\Local\Temp\pip-pip-egg-info-39nmc0pe\matplotlib.egg-info\namespace_packages.txt
    writing requirements to C:\Users\donhuvy\AppData\Local\Temp\pip-pip-egg-info-39nmc0pe\matplotlib.egg-info\requires.txt
    writing top-level names to C:\Users\donhuvy\AppData\Local\Temp\pip-pip-egg-info-39nmc0pe\matplotlib.egg-info\top_level.txt
    writing manifest file 'C:\Users\donhuvy\AppData\Local\Temp\pip-pip-egg-info-39nmc0pe\matplotlib.egg-info\SOURCES.txt'
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\donhuvy\AppData\Local\Temp\pip-install-8bn40qg7\matplotlib\setup.py", line 242, in <module>
        setup(  # Finally, pass this all along to distutils to do the heavy lifting.
      File "D:\Users\donhuvy\PycharmProjects\pythonProject\foo\lib\site-packages\setuptools\__init__.py", line 153, in setup
        return distutils.core.setup(**attrs)
      File "d:\users\donhuvy\appdata\local\programs\python\python39\lib\distutils\core.py", line 148, in setup
        dist.run_commands()
      File "d:\users\donhuvy\appdata\local\programs\python\python39\lib\distutils\dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "d:\users\donhuvy\appdata\local\programs\python\python39\lib\distutils\dist.py", line 985, in run_command
        cmd_obj.run()
      File "D:\Users\donhuvy\PycharmProjects\pythonProject\foo\lib\site-packages\setuptools\command\egg_info.py", line 298, in run
        self.find_sources()
      File "D:\Users\donhuvy\PycharmProjects\pythonProject\foo\lib\site-packages\setuptools\command\egg_info.py", line 305, in find_sources
        mm.run()
      File "D:\Users\donhuvy\PycharmProjects\pythonProject\foo\lib\site-packages\setuptools\command\egg_info.py", line 536, in run
        self.add_defaults()
      File "D:\Users\donhuvy\PycharmProjects\pythonProject\foo\lib\site-packages\setuptools\command\egg_info.py", line 572, in add_defaults
        sdist.add_defaults(self)
      File "d:\users\donhuvy\appdata\local\programs\python\python39\lib\distutils\command\sdist.py", line 228, in add_defaults
        self._add_defaults_ext()
      File "d:\users\donhuvy\appdata\local\programs\python\python39\lib\distutils\command\sdist.py", line 311, in _add_defaults_ext
        build_ext = self.get_finalized_command('build_ext')
      File "d:\users\donhuvy\appdata\local\programs\python\python39\lib\distutils\cmd.py", line 299, in get_finalized_command
        cmd_obj.ensure_finalized()
      File "d:\users\donhuvy\appdata\local\programs\python\python39\lib\distutils\cmd.py", line 107, in ensure_finalized
        self.finalize_options()
      File "C:\Users\donhuvy\AppData\Local\Temp\pip-install-8bn40qg7\matplotlib\setup.py", line 88, in finalize_options
        self.distribution.ext_modules[:] = [
      File "C:\Users\donhuvy\AppData\Local\Temp\pip-install-8bn40qg7\matplotlib\setup.py", line 91, in <listcomp>
        for ext in package.get_extensions()
      File "C:\Users\donhuvy\AppData\Local\Temp\pip-install-8bn40qg7\matplotlib\setupext.py", line 345, in get_extensions
        add_numpy_flags(ext)
      File "C:\Users\donhuvy\AppData\Local\Temp\pip-install-8bn40qg7\matplotlib\setupext.py", line 469, in add_numpy_flags
        import numpy as np
      File "D:\Users\donhuvy\PycharmProjects\pythonProject\foo\lib\site-packages\numpy\__init__.py", line 305, in <module>
        _win_os_check()
      File "D:\Users\donhuvy\PycharmProjects\pythonProject\foo\lib\site-packages\numpy\__init__.py", line 302, in _win_os_check
        raise RuntimeError(msg.format(__file__)) from None
    RuntimeError: The current Numpy installation ('D:\\Users\\donhuvy\\PycharmProjects\\pythonProject\\foo\\lib\\site-packages\\numpy\\__init__.py') fails to pass a sanity check due to a bug in the windows runtime. See this issue for more information: https://tinyurl.com/ y3dm3h86
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
(foo) PS D:\Users\donhuvy\PycharmProjects\pythonProject\foo>

错误信息链接到https://developercommunity.visualstudio.com/content/problem/1207405/fmod-after-an-update-to-windows-2004-is-causing-a.html

使用 Pycharm 2020.2 Ultimate 也会捕获错误。

如何解决?

【问题讨论】:

问题是solved numpy 1.19.5,发布于 2021-01-05。 你可以发布新的答案,这个问题很受关注。 实际上,我不能(问题已关闭)。但这并不重要。 【参考方案1】:

临时解决办法是使用numpy 1.19.3。

pip install numpy==1.19.3

来自this 微软线程修复将于 2021 年 1 月左右推出。

更新: 它已在 KB4598291 update 中修复

【讨论】:

第二种临时解决方案可能是使用 Miniconda for Windows。 我的也是一个类似的问题,在 Windows 机器上安装了 MoviePy (1.0.3),这个 Numpy 版本降级也解决了这个问题。谢谢... 解决了我在 Pycharm 和 windows 上的问题。我将安装的版本从 1.19.4 更改为 1.19.3 现在是四月。这个问题解决了吗?我可以安装 numpy 1.20 吗?? @Uri 是的,这已在 2 月解决

以上是关于RuntimeError:由于Windows运行时中的错误,当前的Numpy安装未能通过完整性检查[重复]的主要内容,如果未能解决你的问题,请参考以下文章

第二次运行 pyqtgraph 时发生 RuntimeError

RuntimeError:cuda 运行时错误(710):设备端断言触发于

RuntimeError:在运行 openerp 时调用 Python 对象时超出了最大递归深度

RuntimeError:无法初始化 API,可能是无效的 tessdata 路径:<>

RuntimeError: GPU:0 上的 CUDA 运行时隐式初始化失败。状态:所有支持 CUDA 的设备都忙或不可用

Matplotlib 和 :RuntimeError: 主线程不在主循环中: