# Module not found but it's already installed

**URL:** <https://discuss.python.org/t/module-not-found-but-its-already-installed/49528>\
**Category:** Python Help\
**Created:** [March 26, 2024, 10:39am UTC](https://discuss.python.org/t/module-not-found-but-its-already-installed/49528 "2024-03-26T10:39:01Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![c-rob](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/c-rob/32/17261_2.png) [@c-rob](https://discuss.python.org/u/c-rob)\
**Post date:** [March 26, 2024, 10:39am UTC](https://discuss.python.org/t/module-not-found-but-its-already-installed/49528/1 "2024-03-26T10:39:01Z")

</div>

- I’m fairly new to Python. I use Python 3.11.8 (what MS Azure supports, my eventual production environment) on Windows 10.
- I’m testing a program on Windows 10.
- I have created and activated my virtual environment in the cmd.exe window.
- My program is in `c:\users\MYUSER\onedrive - CONAME\documents\pythonprojects\CONAME\CUSTNAME\buscard\buscard.py`
- This program worked last week just fine. The only thing that changed is at the top of the program, I changed the order of imports to make importing my custom utils (call it `ggutils.py`) last as I may have to change the sys.path right before I import ggutils. But the error happens before I change the sys.path.
- Imports of standard modules work fine. Pandas has to be installed separately. That’s the one that fails.
- I edit my program in VS Code but run it in cmd.exe with the command line: `py -m pdb buscard.py input "Test 1"`

Here is my code:

```python
import os
import re
import sys
print("Sys.path is:",sys.path)
import glob # To get list of files.
import inspect
from pathlib import Path
import pandas # NOT FOUND
import shutil
import xmltodict
sys.path.append(sys.path[0] + r"c:\users\MYUSER\Pycharmprojects\ggutil2024") # Required to use ggutil
from ggutil import * # My Custom utils.

```

When I run my buscard.py program and I get to a line `import pandas` then I get an error “Module not found”. When I go to cmd.exe and run `pip install pandas` I get “Requirements already satisfied”.

I’m not sure what I’m doing wrong here. I ran the program the same way last week via cmd.exe and it worked fine.

Can someone help please? Thank you.

---

<div class="post-metadata">

**Author:** ![barry-scott](https://avatars.discourse-cdn.com/v4/letter/b/e9c0ed/32.png) [@barry-scott](https://discuss.python.org/u/barry-scott)\
**Post date:** [March 26, 2024, 10:43am UTC](https://discuss.python.org/t/module-not-found-but-its-already-installed/49528/2 "2024-03-26T10:43:16Z")

</div>

The python that pandas is installed for is not the same as the one you are running your code for.

Try using `py -m pip install pandas` and not `pip`.

Running `pip --version` will report which python it is installed for.  
Compare that with `py -m pip --version`

---

<div class="post-metadata">

**Author:** ![c-rob](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/c-rob/32/17261_2.png) [@c-rob](https://discuss.python.org/u/c-rob)\
**Post date:** [March 26, 2024, 10:48am UTC](https://discuss.python.org/t/module-not-found-but-its-already-installed/49528/3 "2024-03-26T10:48:32Z")

</div>

You were right. My current pip is for Python 3.9, the old one I’m not using.

I don’t have a pip for python 3.11 which I’m using.

~~How do I install pip for my Python 3.11? Is that possible?~~ I’m looking how to install pip myself for Python 3.11.

When I run `py -m pip install pandas` I get an error “C:\Users\chuck\AppData\Local\Programs\Python\Python311\python.exe: No module named pip”

When I open a cmd.exe window it runs a program to set up paths called addpath.bat. I’m changing that now to point to Python 3.11.

I’m also checking Windows user environment variables, and fixed those to point to Python 3.11.

---

<div class="post-metadata">

**Author:** ![c-rob](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/c-rob/32/17261_2.png) [@c-rob](https://discuss.python.org/u/c-rob)\
**Post date:** [March 26, 2024, 11:02am UTC](https://discuss.python.org/t/module-not-found-but-its-already-installed/49528/4 "2024-03-26T11:02:18Z")

</div>

Got pip installed. This works for Python 3.11: `py -m ensurepip --upgrade`

The command is now `pip3` not `pip`. It was installed in `C:\Users\MYUSER\AppData\Local\Programs\Python\Python311\Scripts` so make sure your path points to there.

I will put updates below in this message:

- Program seems to be working now. I will test my custom utils file now.

Thank you so much! I’m still new to this. 🙂

---

<div class="post-metadata">

**Author:** ![barry-scott](https://avatars.discourse-cdn.com/v4/letter/b/e9c0ed/32.png) [@barry-scott](https://discuss.python.org/u/barry-scott)\
**Post date:** [March 26, 2024, 12:10pm UTC](https://discuss.python.org/t/module-not-found-but-its-already-installed/49528/5 "2024-03-26T12:10:31Z")

</div>

> [@c-rob](#):
>
> Got pip installed. This works for Python 3.11: `py -m ensurepip --upgrade`

FYI ensurepip is never required with a [python.org](http://python.org) installation.

Glad you have it working.

---

<div class="post-metadata">

**Author:** ![kknechtel](https://avatars.discourse-cdn.com/v4/letter/k/e47c2d/32.png) [@kknechtel](https://discuss.python.org/u/kknechtel)\
**Post date:** [March 26, 2024, 10:47pm UTC](https://discuss.python.org/t/module-not-found-but-its-already-installed/49528/6 "2024-03-26T22:47:24Z")

</div>

> [@c-rob](#):
>
> - I have created and activated my virtual environment in the cmd.exe window.

What is the path to the virtual environment?

Do you intend to use it to run this code?

Do you intend for Pandas to be installed in that virtual environment?

> [@c-rob](#):
>
> I edit my program in VS Code but run it in cmd.exe with the command line: `py -m pdb buscard.py input "Test 1"`

What result do you get from `py -c "import sys; print(sys.executable)"`?

> [@c-rob](#):
>
> When I go to cmd.exe and run `pip install pandas` I get “Requirements already satisfied”.

~~What result do you get from `where pip`, `pip --version` and `py -m pip version`?~~ It looks like you diagnosed this part of the puzzle already.

> [@c-rob](#):
>
> When I run `py -m pip install pandas` I get an error “C:\Users\chuck\AppData\Local\Programs\Python\Python311\python.exe: No module named pip”
> 
> Got pip installed. This works for Python 3.11: `py -m ensurepip --upgrade`

How did you install the 3.11 Python, exactly? Everything you get from the Python website should include Pip already.

> [@c-rob](#):
>
> The command is now `pip3` not `pip`. It was installed in `C:\Users\MYUSER\AppData\Local\Programs\Python\Python311\Scripts`

Are you generally familiar with why this is done or would you be interested in an overview?

---

<div class="post-metadata">

**Author:** ![c-rob](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/c-rob/32/17261_2.png) [@c-rob](https://discuss.python.org/u/c-rob)\
**Post date:** [March 27, 2024, 9:34am UTC](https://discuss.python.org/t/module-not-found-but-its-already-installed/49528/7 "2024-03-27T09:34:09Z")

</div>

> [@kknechtel](#):
>
> How did you install the 3.11 Python, exactly? Everything you get from the Python website should include Pip already.

I downloaded a Windows installer file from [Python.org](http://Python.org). I always start with the official website for that.

I got it working. Thanks for your help.

---

<div class="post-metadata">

**Author:** ![c-rob](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/c-rob/32/17261_2.png) [@c-rob](https://discuss.python.org/u/c-rob)\
**Post date:** [March 27, 2024, 9:35am UTC](https://discuss.python.org/t/module-not-found-but-its-already-installed/49528/8 "2024-03-27T09:35:31Z")

</div>

> Are you generally familiar with why this is done or would you be interested in an overview?

In Python 3.9 I used `pip`. But in Python 3.11 it was renamed to `pip3`. In a tutorial I saw that was done on a Mac he also used `pip3` for Python 3.x. I’d be interested to know why.

---

<div class="post-metadata">

**Author:** ![barry-scott](https://avatars.discourse-cdn.com/v4/letter/b/e9c0ed/32.png) [@barry-scott](https://discuss.python.org/u/barry-scott)\
**Post date:** [March 27, 2024, 9:58am UTC](https://discuss.python.org/t/module-not-found-but-its-already-installed/49528/9 "2024-03-27T09:58:34Z")

</div>

There are two worlds of python commands Windows and the rest, macOS and Unix.

On Windows its been a matter of changing the PATH to point at the version of python, and its tools like pip, that you want to use. If you look in the `Scripts` folder you will see that python3.12, for example, has pip.exe, pip3.exe and pip3.12.exe.

However after the `py` command was added there is a more robust way. Use `py` to start python and `py -m pip` to start pip.

If you install more then one version of python on Windows you can run the exact version you want using `py -3.10` and `py -3.12`. To run the matching pip you can use `py -3.10 -m pip`. This avoids the need to change the PATH.

On the rest, macOS and Unix, python installs with multiple names.  
For example for python 3.12 there will be `python3.12` and, often, `python3` as a symlink to `python3.12`.  
If you install multiple versions of python then you would have `python3.10` etc.

The same naming is done for pip versions that match python versions.  
`pip3.12`, `pip3.10` and `pip3` as a symlink to one of them.

Lastly why is pip called `pip3`? Becuase of python 2 already using the `pip` name.
