0

I have a problem, I recently installed python through the microsoft store (It's my first time using python), and tried to run a script. I have installed numpy and all other modules needed using pip in the commandprompt. But I still get a error, I've tried to fix it but couldn't.

Here's my code:

import numpy as np
import cv2
cap = cv2.VideoCapture(0)
cap.set(3,640) # set Width
cap.set(4,480) # set Height
while(True):
    ret, frame = cap.read()
    frame = cv2.flip(frame, -1) # Flip camera vertically
    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    cv2.imshow('frame', frame)
    cv2.imshow('gray', gray)

    k = cv2.waitKey(30) & 0xff
    if k == 27: # press 'ESC' to quit
        break
cap.release()
cv2.destroyAllWindows()

Yes I tried to just import numpy using "import numpy".

Here's the error:

====== RESTART: C:\Users\Bruger\Desktop\Facial recognition\camera_test.py ======
Traceback (most recent call last):
  File "C:\Users\Bruger\Desktop\Facial recognition\camera_test.py", line 1, in <module>
    import numpy as np
  File "C:\Users\Bruger\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\numpy\__init__.py", line 305, in <module>
    _win_os_check()
  File "C:\Users\Bruger\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\numpy\__init__.py", line 302, in _win_os_check
    raise RuntimeError(msg.format(__file__)) from None
RuntimeError: The current Numpy installation ('C:\\Users\\Bruger\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python38\\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://developercommunity.visualstudio.com/content/problem/1207405/fmod-after-an-update-to-windows-2004-is-causing-a.html

1 Answers1

0

You will need to install numpy==1.19.3 for it to work. So you will have to do:

  1. pip uninstall numpy to uninstall numpy
  2. pip install numpy==1.19.3 to install version 1.19.3 of numpy
abhigyanj
  • 2,355
  • 2
  • 9
  • 29