Home > Blockchain >  Module "Numpy" not found despite already installed in system
Module "Numpy" not found despite already installed in system

Time:11-22

I have a problem thats been stumping me for days. I wanted to run this GAIN program on my local system though command line (https://github.com/jsyoon0823/GAIN) so I downloaded it, installed Python for the first time because

Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.

then created a virtual environment. I ran pip install -r requirements.txt (logs) When I ran the program it said

(GAINenv) C:\Users\Admin\Downloads\GAIN-master\GAIN-master>python3 main_letter_spam.py --data_name spam --miss_rate: 0.2 --batch_size 128 --hint_rate 0.9 --alpha 100 --iterations 10000
Traceback (most recent call last):
  File "C:\Users\Admin\Downloads\GAIN-master\GAIN-master\main_letter_spam.py", line 24, in <module>
    import numpy as np
ModuleNotFoundError: No module named 'numpy'

I was confused because they said in the logs numpy was installed. So I did the following:

  1. checked GAINenv\Lib\site-packages for numpy. It was already there written as numpy. In the import, it was also written as import numpy as np
  2. checked if there are multiple Python installations. There aren't
  3. ran pip install numpy. It said Requirement already satisfied: numpy in c:\users\admin\downloads\gain-master\gain-master\gainenv\lib\site-packages (1.23.5)
  4. forced install pip install -I numpy. Ran the command and got the same no module error
  5. Added the path in virtual env then reset the command prompt window. Same error
  6. did pip3 and pip2 install. Still no module error
  7. downloaded numpy directly from sourceforge then installed it in virtualenv directory. Doesn't work

Here is the list of similar questions I read but didn't work:

  1. No module named 'numpy' but Requirement already satisfied: numpy
  2. Error "Import Error: No module named numpy" on Windows
  3. 'Python not found' despite having been installed
  4. https://unix.stackexchange.com/questions/93097/numpy-module-not-found-despite-being-in-path
  5. NumPy module not found after install
  6. Python Module not found despite being installed
  7. no module named numpy despite numpy being already installed
  8. Pyaudio module not found despite being installed

This is what happens when I run python -m site

(GAINenv) C:\Users\Admin\Downloads\GAIN-master\GAIN-master>python -m site
sys.path = [
    'C:\\Users\\Admin\\Downloads\\GAIN-master\\GAIN-master',
    'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\\python310.zip',
    'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\\DLLs',
    'C:\\Program Files\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_3.10.2288.0_x64__qbz5n2kfra8p0\\lib',
    'C:\\Users\\Admin\\AppData\\Local\\Microsoft\\WindowsApps\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0',
    'C:\\Users\\Admin\\Downloads\\GAIN-master\\GAIN-master\\GAINenv',
    'C:\\Users\\Admin\\Downloads\\GAIN-master\\GAIN-master\\GAINenv\\lib\\site-packages',
]
USER_BASE: 'C:\\Users\\Admin\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages' (exists)
USER_SITE: 'C:\\Users\\Admin\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages' (exists)
ENABLE_USER_SITE: False

I don't care about Anaconda and PyCharm because I simply want to run a python script locally through command line.

I'm using Windows 10 and Python 3.10 from Microsoft Store. Thanks in advance!

CodePudding user response:

The following command worked for me:

python.exe -m pip install numpy

Or:

Download and install

http://sourceforge.net/projects/numpy/files/NumPy/

$ tar xfz numpy-n.m.tar.gz
$ cd numpy-n.m
$ python setup.py install

CodePudding user response:

I uninstalled Python 3.10 Microsoft Store, installed Python 3.10 for Windows from the official website, and ran the program without virtual environment.

  • Related