# Numpy is not working

**URL:** <https://discuss.python.org/t/numpy-is-not-working/44246>\
**Category:** Python Help\
**Created:** [January 26, 2024, 6:37pm UTC](https://discuss.python.org/t/numpy-is-not-working/44246 "2024-01-26T18:37:39Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![MikeSmith](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@MikeSmith](https://discuss.python.org/u/MikeSmith)\
**Post date:** [January 26, 2024, 6:37pm UTC](https://discuss.python.org/t/numpy-is-not-working/44246/1 "2024-01-26T18:37:39Z")

</div>

I have followed all the steps for:

- pip install numpy

But when I run “import numpy” in python, I get the error message “module numpy not found”.

Mike

---

<div class="post-metadata">

**Author:** ![jamestwebber](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/jamestwebber/32/12799_2.png) [@jamestwebber](https://discuss.python.org/u/jamestwebber)\
**Post date:** [January 26, 2024, 6:41pm UTC](https://discuss.python.org/t/numpy-is-not-working/44246/2 "2024-01-26T18:41:22Z")

</div>

Two possibilities come to mind:

1. Did `pip install numpy` complete successfully? You said that you ran it, but not what the output was. Perhaps something went wrong.
2. Was the `pip` you used tied to the installation of `python` you are trying to import numpy in? There might be multiple versions on your system, and `pip` might point somewhere unexpected. A simple way to ensure this is to use the (recommended) installation method `python -m pip install numpy`, which will help make sure that the `python` binary is the same in both cases.

---

<div class="post-metadata">

**Author:** ![onePythonUser](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/onepythonuser/32/19158_2.png) [@onePythonUser](https://discuss.python.org/u/onePythonUser)\
**Post date:** [January 26, 2024, 7:02pm UTC](https://discuss.python.org/t/numpy-is-not-working/44246/3 "2024-01-26T19:02:19Z")

</div>

Hi,

you might have the same problem another user had about ~two weeks ago. The issue arises when  
downloading a new module into the search path of a different Python version. For example, if you  
are using Python v3.12 but numpy was downloaded into your v3.8, then you will run into this issue. So that you don’t run into this issue, uninstall ALL previous versions from your system and make sure you have the latest and greatest version of Python installed. You will have to perform the pip install again since I am assuming the numpy library was downloaded to the earlier version of the Python directory of which you have now uninstalled.

An easy way to tell is execute the following code snippet:

```python
import sys
paths = sys.path
num = 1
for path in paths:
    print('{}. {}'.format(num, path))
    num += 1

```

There, you will see your active PYTHONPATH. In the search paths, you’ll see the active  
search directories including python versions.

**Update:**  
If you don’t want to uninstall your previous version, then make sure the directory is part of the active PYTHONPATH via the following commands:

```python
 sys.path.append(r'C:\folder1\folder2\folder_n') # Add your directory path here

```

where _C:\folder1\folder2\folder\_n_ is the location of the **numpy** library package.

Or open the same IDLE version where your numpy library package was downloaded to., of course. 😉

---

<div class="post-metadata">

**Author:** ![jeff5](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/jeff5/32/1518_2.png) [@jeff5](https://discuss.python.org/u/jeff5)\
**Post date:** [January 26, 2024, 8:33pm UTC](https://discuss.python.org/t/numpy-is-not-working/44246/4 "2024-01-26T20:33:53Z")

</div>

Somewhat prefer:

```python
>>> import sys, pprint
>>> pprint.pprint(sys.path)

```

But yes. The important thing @MikeSmith is to do it in the script where your import didn’t work.

Then, where you used the pip command `pip debug` will tell you what Python it runs with and what `site-packages` it comes from. This is also where it installed numpy (if it worked).

Are they the same?

---

<div class="post-metadata">

**Author:** ![jeff5](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/jeff5/32/1518_2.png) [@jeff5](https://discuss.python.org/u/jeff5)\
**Post date:** [January 26, 2024, 8:40pm UTC](https://discuss.python.org/t/numpy-is-not-working/44246/5 "2024-01-26T20:40:34Z")

</div>

> [@onePythonUser](#):
>
> If you don’t want to uninstall your previous version, then make sure the directory is part of the active PYTHONPATH via the following commands:
> 
> ```python
> sys.path.append(r'C:\folder1\folder2\folder_n') # Add your directory path here
> 
> ```
> 
> where _C:\folder1\folder2\folder\_n_ is the location of the **numpy** library package.

I’d caution against this approach because:

1. A package installed for one Python does not necessarily work in another.
2. Your code is not portable: it only runs on your machine with these directories.

It’s better to figure out why `pip` and your script are not using the same installation and solve this by setting your executable search path consistently.

---

<div class="post-metadata">

**Author:** ![MikeSmith](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@MikeSmith](https://discuss.python.org/u/MikeSmith)\
**Post date:** [January 27, 2024, 1:29am UTC](https://discuss.python.org/t/numpy-is-not-working/44246/6 "2024-01-27T01:29:45Z")

</div>

Jeff:

`import sys, pprint`  
does nothing

`pprint.pprint(sys.path)`  
prints out several paths as per the attached screen capture.

Which path is correct?

Mike

 ![PrintScreen01](https://us1.discourse-cdn.com/flex002/uploads/python1/original/3X/d/4/d442f8860b5b776ba924777b15497882da00e525.jpeg)

---

<div class="post-metadata">

**Author:** ![MikeSmith](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@MikeSmith](https://discuss.python.org/u/MikeSmith)\
**Post date:** [January 27, 2024, 1:37am UTC](https://discuss.python.org/t/numpy-is-not-working/44246/7 "2024-01-27T01:37:27Z")

</div>

James:  
The answer I got was that numpy was installed already.

I am attaching a screen capture.

Mike

 ![PrintScreen02](https://us1.discourse-cdn.com/flex002/uploads/python1/original/3X/5/f/5faa2301c1d37fd968d4089f7ca5891a0ed27fa1.jpeg)

---

<div class="post-metadata">

**Author:** ![MikeSmith](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@MikeSmith](https://discuss.python.org/u/MikeSmith)\
**Post date:** [January 27, 2024, 1:47am UTC](https://discuss.python.org/t/numpy-is-not-working/44246/8 "2024-01-27T01:47:25Z")

</div>

Paul:

I ran the code and got results as per the screen capture.

Which path is best?

Mike

 ![PrintScreen04](https://us1.discourse-cdn.com/flex002/uploads/python1/original/3X/c/8/c883fd3460768960a79da80d5b5c8a04f2fc9bdf.jpeg)

---

<div class="post-metadata">

**Author:** ![onePythonUser](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/onepythonuser/32/19158_2.png) [@onePythonUser](https://discuss.python.org/u/onePythonUser)\
**Post date:** [January 27, 2024, 1:51am UTC](https://discuss.python.org/t/numpy-is-not-working/44246/9 "2024-01-27T01:51:44Z")

</div>

Open a new Python IDLE editor and type the following:

```python
import os
os.getcwd()

```

what do you get? This is to make sure and compare that the right IDLE version is the default (in this case v3.12 as per the list printed above)

By the way, the numpy package should have been installed here (at least on my system):  
C:\Users\mycom\AppData\Local\Programs\Python\Python312\Lib\site-packages

Have you tried importing numpy again? It looks like the defaults are pointing to the latest IDLE. Can you verify by trying the following again:

```python
import numpy

```

Check here for the numpy download location on your system (copy and paste on a file search header):  
C:\Users\donca\AppData\Local\Programs\Python\Python312\Lib\site-packages\numpy

---

<div class="post-metadata">

**Author:** ![jkloth](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/jkloth/32/253_2.png) [@jkloth](https://discuss.python.org/u/jkloth)\
**Post date:** [January 27, 2024, 2:00am UTC](https://discuss.python.org/t/numpy-is-not-working/44246/10 "2024-01-27T02:00:07Z")

</div>

This screenshot shows that you are using a virtual environment (venv). By default, venv’s do not have access to packages installed globally, as in your 2 previous screenshots. Either create the venv with `--system-site-packages`, or use the pip command from the venv (`C:\Users\donca\PycharmProjects\Test02\.venv\Scripts\pip.exe`) to install numpy.

---

<div class="post-metadata">

**Author:** ![jkloth](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/jkloth/32/253_2.png) [@jkloth](https://discuss.python.org/u/jkloth)\
**Post date:** [January 27, 2024, 2:03am UTC](https://discuss.python.org/t/numpy-is-not-working/44246/11 "2024-01-27T02:03:01Z")

</div>

> [@onePythonUser](#):
>
> By the way, the numpy package should have been installed here (at least on my system):  
> C:\Users\mycom\AppData\Local\Programs\Python\Python312\Lib\site-packages

The location listed by @MikeSmith is from a Windows Store installation of Python which is just as usable as a [python.org](http://python.org) installation (it is the exact same files in both).

---

<div class="post-metadata">

**Author:** ![jeff5](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/jeff5/32/1518_2.png) [@jeff5](https://discuss.python.org/u/jeff5)\
**Post date:** [January 27, 2024, 7:24am UTC](https://discuss.python.org/t/numpy-is-not-working/44246/12 "2024-01-27T07:24:23Z")

</div>

> [@MikeSmith](#):
>
> Which path is correct?

It’s not a question of which is right or best. This is the list of places the Python interpreter will look for imports. All we’re doing here is exploring why `numpy` is not found.

I can see from this and the answer you gave James @jamestwebber that `pip` has installed `numpy` in one of these places (the one with `site-packages` in the name). I’m fairly confident that if you had typed `import numpy` in the Python session you started at the console it would have worked.

Now, when you answer Paul @onePythonUser , I can see that you are running his suggested script in PyCharm, and as Jeremy @jkloth effectively points out, PyCharm is running your code in a virtual environment, which is a sort of isolated installation of Python just for your project. It has its own `site-packages`, not the one where `pip` installed `numpy`. I would guess the place where `import numpy` didn’t work for you was in a PyCharm project. That’s why I wrote:

> [@jeff5](#):
>
> The important thing @MikeSmith is to do it in the script where your import didn’t work.

It seems annoying at the moment, but it is in fact very useful to have your project isolated like this, so it works the same way whatever you may have installed for some other project.

The easy solution is to get PyCharm to install `numpy` for that project. At the place where you import numpy in the PyCharm editor, without installing it for the project, it should catch your mistake and if you hover the mouse on the red underline, it will offer to do the installation, like this:  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/python1/original/3X/f/1/f1a4358a66ec5c3802e6d470191268a580336a2a.png)

By the way, if you’re posting code or error messages, people prefer that you not use an image, but paste the code than mark it up [using the “\</\>” button or by typing back-ticks](https://discuss.python.org/t/about-the-python-help-category/42). I used an image here so you could see the hover.

---

<div class="post-metadata">

**Author:** ![MikeSmith](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@MikeSmith](https://discuss.python.org/u/MikeSmith)\
**Post date:** [January 27, 2024, 11:21am UTC](https://discuss.python.org/t/numpy-is-not-working/44246/13 "2024-01-27T11:21:47Z")

</div>

Jeff:

Yes, it worked! I think I am out of the woods.

Thank you so much.

Mike

---

<div class="post-metadata">

**Author:** ![MikeSmith](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@MikeSmith](https://discuss.python.org/u/MikeSmith)\
**Post date:** [January 27, 2024, 11:38am UTC](https://discuss.python.org/t/numpy-is-not-working/44246/14 "2024-01-27T11:38:43Z")

</div>

Thank you Jeremy:

You are right, I downloaded the numpy package from the Microsoft Store.

I have added the link for [Python.org](http://Python.org) to me favourites.

Thanks again.

Mike

---

<div class="post-metadata">

**Author:** ![MikeSmith](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@MikeSmith](https://discuss.python.org/u/MikeSmith)\
**Post date:** [January 27, 2024, 11:44am UTC](https://discuss.python.org/t/numpy-is-not-working/44246/15 "2024-01-27T11:44:18Z")

</div>

Jeremy:  
I eventually installed numpy by hovering over “import numpy” and followed the prompts as per Jeff’s advice.  
Its outlined above.  
It worked well.  
Mike

---

<div class="post-metadata">

**Author:** ![MikeSmith](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@MikeSmith](https://discuss.python.org/u/MikeSmith)\
**Post date:** [January 27, 2024, 12:08pm UTC](https://discuss.python.org/t/numpy-is-not-working/44246/16 "2024-01-27T12:08:10Z")

</div>

Paul:  
I have numby working now.

I ran the code you suggested and got the screen below.

Mike

 ![PrintScreen06](https://us1.discourse-cdn.com/flex002/uploads/python1/original/3X/6/0/60942fd760c6e9daa5710c0c056f64be485a4dfe.jpeg)

---

<div class="post-metadata">

**Author:** ![onePythonUser](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/onepythonuser/32/19158_2.png) [@onePythonUser](https://discuss.python.org/u/onePythonUser)\
**Post date:** [January 27, 2024, 5:16pm UTC](https://discuss.python.org/t/numpy-is-not-working/44246/17 "2024-01-27T17:16:37Z")

</div>

Glad to know you got it figured out. 🙂

For future reference, make sure when you are installing Python library packages, that they are being  
installed to your active PYTHONPATH and not to either a previous version of Python or some virtual environment.

Cheers!

---

<div class="post-metadata">

**Author:** ![MikeSmith](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@MikeSmith](https://discuss.python.org/u/MikeSmith)\
**Post date:** [January 27, 2024, 6:01pm UTC](https://discuss.python.org/t/numpy-is-not-working/44246/18 "2024-01-27T18:01:30Z")

</div>

Paul:

Just for clarification.

I have learned how to install an application from inside PyCharm. That’s how I got numpy to work.

Is that the method to use to assure that it goes into the PyhthonPath?

Mike

---

<div class="post-metadata">

**Author:** ![onePythonUser](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/onepythonuser/32/19158_2.png) [@onePythonUser](https://discuss.python.org/u/onePythonUser)\
**Post date:** [January 27, 2024, 6:22pm UTC](https://discuss.python.org/t/numpy-is-not-working/44246/19 "2024-01-27T18:22:18Z")

</div>

As a disclaimer, I don’t and have never used **PyCharm**. However, I think that if you are using PyCharm, it will have its own designated **PYTHONPATH** just like **IDLE** does (which is what I use).

For example:

PyCharm → PYTHONPATH\_1 (the path that PyCharm will search when importing modules)

IDLE → PYTHONPATH\_2 (the path that IDLE will search when importing modules)

```python
PYTHONPATH_1 != PYTHONPATH_2 # they may not be equal

```

Note here that I have added the `_1` and `_2` as arbitrary (to tell them apart). So, when I download library packages, they will be downloaded to the path as designated by [python.org](http://python.org) (IDLE). Being that you use PyCharm, it will have its own designated download path. So, what is the take away here, make sure that you are consistent with the environment that you are using or at the very least keep tabs on the path where you’re downloading the library packages to.

Remember, PYTHONPATHs are where your system searches for importing library packages that either come prepackaged with your Python environment or the ones that you download via `pip`.

Next time you run into this issue, you now have the experience to rectify it.

---

<div class="post-metadata">

**Author:** ![MikeSmith](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@MikeSmith](https://discuss.python.org/u/MikeSmith)\
**Post date:** [January 27, 2024, 9:57pm UTC](https://discuss.python.org/t/numpy-is-not-working/44246/20 "2024-01-27T21:57:42Z")

</div>

Thanks Paul:

Mike

[Next page](https://discuss.python.org/t/numpy-is-not-working/44246.md?page=2)
