0

With some help from youtube tutorials, I've been developing an assistant in python similar to that of Jarvis from the marvel movies. Every time I run the program I get the following Runtime Error:

RuntimeError: The current Numpy installation ('C:\\Python\\Python 3.9\\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: 
    
Process finished with exit code 1

Here is the full Traceback:

    "C:\Python\Python 3.9\python.exe" C:/M.A.R.T.I.N/martin.py
      File "C:\M.A.R.T.I.N\martin.py", line 6, in <module>
        engine = pyttsx3.init()
      File "C:\Python\Python 3.9\lib\site-packages\pyttsx3\__init__.py", line 22, in init
        eng = Engine(driverName, debug)
      File "C:\Python\Python 3.9\lib\site-packages\pyttsx3\engine.py", line 30, in __init__
        self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
      File "C:\Python\Python 3.9\lib\site-packages\pyttsx3\driver.py", line 50, in __init__
        self._module = importlib.import_module(name)
      File "C:\Python\Python 3.9\lib\importlib\__init__.py", line 127, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
      File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
      File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 790, in exec_module
      File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
      File "C:\Python\Python 3.9\lib\site-packages\pyttsx3\drivers\sapi5.py", line 1, in <module>
        import comtypes.client  # Importing comtypes.client will make the gen subpackage
      File "C:\Python\Python 3.9\lib\site-packages\comtypes\__init__.py", line 1176, in <module>
        class IPersist(IUnknown):
      File "C:\Python\Python 3.9\lib\site-packages\comtypes\__init__.py", line 1180, in IPersist
        COMMETHOD([], HRESULT, 'GetClassID',
      File "C:\Python\Python 3.9\lib\site-packages\comtypes\__init__.py", line 1099, in COMMETHOD
        from comtypes.automation import VARIANT
      File "C:\Python\Python 3.9\lib\site-packages\comtypes\automation.py", line 12, in <module>
        from comtypes import npsupport
      File "C:\Python\Python 3.9\lib\site-packages\comtypes\npsupport.py", line 5, in <module>
        import numpy
      File "C:\Python\Python 3.9\lib\site-packages\numpy\__init__.py", line 305, in <module>
        _win_os_check()
      File "C:\Python\Python 3.9\lib\site-packages\numpy\__init__.py", line 302, in _win_os_check
        raise RuntimeError(msg.format(__file__)) from None
    RuntimeError: The current Numpy installation ('C:\\Python\\Python 3.9\\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: 
    
    Process finished with exit code 1

I don't know what mistakes I made but here's my code.

    import pyttsx3
    import datetime
    import speech_recognition as sr
    import webbrowser
    
    engine = pyttsx3.init()
    
    
    def speak(audio):
        engine.say(audio)
        engine.runAndWait()
    
    
    def time():
        Time = datetime.datetime.now().strftime("%I: %M: %S")
        speak(Time)
    
    
    def date():
        year = int(datetime.datetime.now().year)
        month = int(datetime.datetime.now().month)
        day = int(datetime.datetime.now().day)
        speak(day)
        speak(month)
        speak(year)
    
    
    def wishme():
        speak("Welcome back sir!")
        speak("How may I help you?")
    
    
    def takeCommand(ask):
        if ask:
            print(ask)
        r = sr.Recognizer()
        with sr.Microphone() as source:
            print("Listening...")
            r.pause_threshold = 1
            audio = r.listen(source)
            voice_data = ' '
    
        try:
            print("Recognizing...")
            voice_data = r.recognize_google(audio)
            print(voice_data)
    
        except Exception as e:
            print(e)
            speak("Say that again please sir...")
    
            return "none"
        return voice_data
    
    
    def respond(voice_data):
        if 'what is your name' in voice_data:
            speak("My name is MARTIN")
        if 'search' in voice_data:
            search = takeCommand(ask=speak('what do you want to search for?'))
            url = 'https://google.com/search?q=' + search
            webbrowser.get().open(url)
        if 'find location' in voice_data:
            location = takeCommand(ask=speak('what place do you want to search for?'))
            url = 'https://google.nl/maps/place/' + location
            webbrowser.get().open(url)
        if 'thank you' in voice_data:
            speak("You're welcome sir")
        if 'Martin not now' in voice_data:
            speak(" ")
        if 'exit' in voice_data:
            exit()
    
    
    
    
    wishme()
    
    voice_data = takeCommand(ask=True)
    respond(voice_data)

Please let me know what I did wrong.

lys
  • 949
  • 2
  • 9
  • 33

1 Answers1

0

There is a clue here:

RuntimeError: The current Numpy installation ('C:\Python\Python 3.9\lib\site-packages\numpy\init.py') fails to pass a sanity check due to a bug in the windows runtime.

Perhaps there is an issue with the version of numpy you have installed.

First uninstall numpy:

pip uninstall numpy

Then try the solution for the runtime error you provided seen here:

The temporary solution is to use numpy 1.19.3.

pip install numpy==1.19.3

From this Microsoft thread fix will be available around January 2021.

From what I can tell, it looks like you're running this in Python 3.9 and that you aren't running this inside a virtual environment It is advisable to use virtual environments to manage projects which require different Python versions and dependencies/modules.

lys
  • 949
  • 2
  • 9
  • 33