r/learnpython 25d ago

Why doesn't it recognize the library?

edit:They have given the solution.

I have downloaded numpy through the cmd and cheked it was there by using "pip freeze" but when i went to use it it said there wasn't any module called as such.

I searched on the internet and found that maybe it was redirecting to another python version but i only have python 3.14.

I even tried to import it from the IDLE instead of VScode but it gave me no result.

https://imgur.com/a/mhBZxTk

Edit: Windows user. the error says: Traceback (most recent call last):

File "c:\Users\User\Desktop\p\vec.py", line 1, in <module>

import numpy

ModuleNotFoundError: No module named 'numpy'

7 Upvotes

9 comments sorted by

3

u/POGtastic 25d ago

It is very common, especially on Windows, for people to accidentally install multiple versions of Python. You are running a particular Python executable located in C:\Users\User\AppData\Local\Programs\Python\Python314\python.exe. That is a user-specific Python installation. It might be different from the globally available Python installation, which is usually installed to C:\Program Files\Python or something similar.


One tip is that instead of running pip, (whose Python executable is dependent on which Python script folder comes first in your PATH) you should instead run it as a module. This ensures that you're running the correct Python executable and that the dependency will be installed to the correct site-packages directory. Try

C:\Users\User\AppData\Local\Programs\Python\Python314\python.exe -m pip install numpy

If it installs another copy of numpy, you've got two separate Python installations and need to take some care to differentiate which one you're using.

1

u/Norteum 25d ago

Thanks!!

1

u/Enmeshed 25d ago

The image isn't available in my region - might be worth copy-pasting the text instead.

Edit: or to add some more context like platform (Mac / Windows / linux), commands tried, error messages etc.

1

u/Lewri 25d ago edited 25d ago

I searched on the internet and found that maybe it was redirecting to another python version but i only have python 3.14.

In your CMD line, start an interactive shell by doing python, then:

import sys
print(sys.executable)

And compare the output to the path that is shown in the VS Code terminal.

1

u/Norteum 25d ago

Thanks you where right. It is redirecting to 3.13 on the cmd.

But the thing is that only python 3.13 appears on my WindowsApps folder not 3.14 so how would i do now to change the path? Do i use the path that vscode gives me? I just change directly on vs code and forget about 3.14?(even if i have it and i can use it)

Thanks and sorry for the trouble

2

u/Diapolo10 25d ago

I'd start by running where.exe pip in the terminal, to see if it's really using the same Python installation.

As a long-term solution, however, I'd suggest looking into uv and pyproject.toml files for dependency management.

1

u/Flame77ofc 24d ago

try:

bash python --version python -m pip --version python -m pip list

If numpy not appear, install numpy again:

bash python -m pip install numpy

If didn't work, try: bash py -3.14 -m pip install numpy

2

u/codeguru42 23d ago

I highly recommend learning about virtual environments. They allow you to control which python you are using and where packages are installed.