# Both Python 2 and Python 3 installed on MacOS, but pip command install libraries only for Python 3

**URL:** <https://discuss.python.org/t/both-python-2-and-python-3-installed-on-macos-but-pip-command-install-libraries-only-for-python-3/7984>\
**Category:** Packaging\
**Tags:** help\
**Created:** [March 30, 2021, 11:24am UTC](https://discuss.python.org/t/both-python-2-and-python-3-installed-on-macos-but-pip-command-install-libraries-only-for-python-3/7984 "2021-03-30T11:24:39Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Barbab](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/barbab/32/3832_2.png) [@Barbab](https://discuss.python.org/u/Barbab)\
**Post date:** [March 30, 2021, 11:24am UTC](https://discuss.python.org/t/both-python-2-and-python-3-installed-on-macos-but-pip-command-install-libraries-only-for-python-3/7984/1 "2021-03-30T11:24:39Z")

</div>

I have both Python 2 and Python 3 installed on my MacOS (Mojave 10.14.5). When I run my Python 2 code I get:  
`ImportError: No module named <modulename>`  
if I install the module with `pip install <modulename>` command i get:  
`Requirement already satisfied: <modulename> in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (0.5)`  
Then same missing package message as before when running the code with Python 2. The command `pip2 install <modulename>` is not working. How could I install modules for Python 2?

---

<div class="post-metadata">

**Author:** ![jwodder](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/jwodder/32/236_2.png) [@jwodder](https://discuss.python.org/u/jwodder)\
**Post date:** [March 30, 2021, 11:53am UTC](https://discuss.python.org/t/both-python-2-and-python-3-installed-on-macos-but-pip-command-install-libraries-only-for-python-3/7984/2 "2021-03-30T11:53:39Z")

</div>

You can ensure you run pip for Python 2 by invoking it as `python2 -m pip ...`.

---

<div class="post-metadata">

**Author:** ![Barbab](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/barbab/32/3832_2.png) [@Barbab](https://discuss.python.org/u/Barbab)\
**Post date:** [March 30, 2021, 11:56am UTC](https://discuss.python.org/t/both-python-2-and-python-3-installed-on-macos-but-pip-command-install-libraries-only-for-python-3/7984/3 "2021-03-30T11:56:24Z")

</div>

> [@jwodder](#):
>
> `python2 -m pip ...` .

Thank for your response, unfortunately from the terminal i get:  
`-bash: python2: command not found`

---

<div class="post-metadata">

**Author:** ![jwodder](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/jwodder/32/236_2.png) [@jwodder](https://discuss.python.org/u/jwodder)\
**Post date:** [March 30, 2021, 12:09pm UTC](https://discuss.python.org/t/both-python-2-and-python-3-installed-on-macos-but-pip-command-install-libraries-only-for-python-3/7984/4 "2021-03-30T12:09:17Z")

</div>

Then use whatever the Python 2 command is called on your system.

---

<div class="post-metadata">

**Author:** ![Barbab](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/barbab/32/3832_2.png) [@Barbab](https://discuss.python.org/u/Barbab)\
**Post date:** [March 30, 2021, 12:14pm UTC](https://discuss.python.org/t/both-python-2-and-python-3-installed-on-macos-but-pip-command-install-libraries-only-for-python-3/7984/5 "2021-03-30T12:14:47Z")

</div>

`python pip install snap python: can't open file 'pip': [Errno 2] No such file or directory`  
`pip2` is not working

---

<div class="post-metadata">

**Author:** ![jwodder](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/jwodder/32/236_2.png) [@jwodder](https://discuss.python.org/u/jwodder)\
**Post date:** [March 30, 2021, 12:27pm UTC](https://discuss.python.org/t/both-python-2-and-python-3-installed-on-macos-but-pip-command-install-libraries-only-for-python-3/7984/6 "2021-03-30T12:27:02Z")

</div>

You left out the `-m` option between `python` and `pip`.

---

<div class="post-metadata">

**Author:** ![Barbab](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/barbab/32/3832_2.png) [@Barbab](https://discuss.python.org/u/Barbab)\
**Post date:** [March 30, 2021, 12:43pm UTC](https://discuss.python.org/t/both-python-2-and-python-3-installed-on-macos-but-pip-command-install-libraries-only-for-python-3/7984/7 "2021-03-30T12:43:35Z")

</div>

Ok, I managed to install the module with `python -m pip install --user the_module`. Now another problem, maybe worst: I need to install the package cvxpy which I think requires at least python 3.7 because It says `RuntimeError: Python version >= 3.7 required.` Is there any possibility to get around this?

---

<div class="post-metadata">

**Author:** ![brettcannon](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/brettcannon/32/34895_2.png) [@brettcannon](https://discuss.python.org/u/brettcannon)\
**Post date:** [March 30, 2021, 7:40pm UTC](https://discuss.python.org/t/both-python-2-and-python-3-installed-on-macos-but-pip-command-install-libraries-only-for-python-3/7984/8 "2021-03-30T19:40:46Z")

</div>

> [@Barbab](#):
>
> I need to install the package cvxpy which I think requires at least python 3.7 because It says `RuntimeError: Python version >= 3.7 required.` Is there any possibility to get around this?

That suggests you are not trying to run the project using Python 3.7 or newer which the project requires. You need to use a newer version of Python, otherwise you will need to personally port the project to whatever version of Python you need support on.
