0

I used command prompt to install numpy by using the following commands

pip3 install numpy

and

python.exe -m install numpy

and it's installed it in my appdata\local\packages\pythonsoftwarefoundation etc folder.

However when trying to import numpy in my python fil in VSCode it gives me "Unable to import 'numpy' pylint(import-error)"

Not sure what the deal is. I've imported other libraries before like discord.py in the same way and it's worked for me. Any help is appreciated.

chimps123
  • 3
  • 1
  • 2
  • That's because python interpreter couldn't detect numpy in the current working environment. It's recommended to create a virtual environment via `python -m venv ` in current working folder, then reinstall numpy. There will be no error shown. About virtual environment, reference: https://code.visualstudio.com/docs/python/environments#_global-virtual-and-conda-environments – Molly Wang-MSFT Sep 29 '20 at 02:38
  • It still gives me the same error, I used ```python -m venv .venv``` in the folder where my .py file is and installed numpy there using ```pip3 install numpy``` but it still said "requirement met, installed in" in my appdata folder and the error persists. – chimps123 Sep 29 '20 at 04:25
  • how about uninstalling the existed modules and reinstalling it again? can you post the error screenshot to the question? – Molly Wang-MSFT Sep 29 '20 at 06:34
  • Have you activated the virtual environment which you just created? – Quanta Sep 29 '20 at 06:55
  • I wasn't aware that I was supposed to activate it, but even after activating it gives me the same error https://imgur.com/a/b52T8CE – chimps123 Sep 29 '20 at 19:37

1 Answers1

0

After installing numpy, use pip show numpy to check if it was installed in current environment:

enter image description here

Then press the green button on the upper right corner, run the file in Terminal.

The module py usage is:

enter image description here

So the right command is py test.py -3, also it's recommended that use the command python to run .py file.

enter image description here

Molly Wang-MSFT
  • 7,943
  • 2
  • 9
  • 22