Digglit
Digglit

Reputation: 686

OpenAI Whisper Cannot Import Numpy

I am trying to run the OpenAI Whisper model but running into the following error when trying to run my script:

ValueError: Unable to compare versions for numpy>=1.17: need=1.17 found=None. This is unusual. Consider reinstalling numpy.

I have, as the error suggests, tried reinstalling Numpy but that didn't solve anything. When I run the command 'pip show numpy' I get:

Name: numpy
Version: 1.23.5
Summary: NumPy is the fundamental package for array computing with Python.
Home-page: https://www.numpy.org
Author: Travis E. Oliphant et al.
Author-email: 
License: BSD
Location: /opt/homebrew/lib/python3.10/site-packages
Requires: 
Required-by: contourpy, matplotlib, pandas, pythran, scipy, transformers, whisper

So not only do I have Numpy version 1.23.5 (>1.17), it also lists whisper as dependent on the package.

My machine is a Macbook Air M1 running OS Ventura 13.0.1.

I have looked through the OpenAI github for similar issues but I can't seem to find anything of the sort. I also tried importing the package manually with this following:

import sys
sys.path.append('/opt/homebrew/lib/python3.10/site-packages/numpy')

But this didn't work either. Please let me know if you have any insight as to why this may be happening.

Upvotes: 1

Views: 6068

Answers (2)

Ketan Mann
Ketan Mann

Reputation: 1

Just update numpy:

pip install --upgrade numpy

Upvotes: 0

Digglit
Digglit

Reputation: 686

I was able to resolve this issue by navigating to the directory printed by 'pip show numpy', which in my case was "/opt/homebrew/lib/python3.10/site-packages"

From there, there were some loose numpy related folders despite uninstalling numpy. I deleted these folders and reinstalled numpy using

python3 -m pip install numpy

After doing this my code worked as expected.

Upvotes: 4

Related Questions