# CMake FindPackage(Python) is not preferring Python3

**URL:** https://discourse.cmake.org/t/cmake-findpackage-python-is-not-preferring-python3/4960
**Category:** Usage
**Tags:** os:linux
**Created:** [February 3, 2022, 4:30pm UTC](https://discourse.cmake.org/t/cmake-findpackage-python-is-not-preferring-python3/4960 "2022-02-03T16:30:02Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![developer](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/bcef8e/32.png) [@developer](https://discourse.cmake.org/u/developer)
#### Post date: [February 3, 2022, 4:30pm UTC](https://discourse.cmake.org/t/cmake-findpackage-python-is-not-preferring-python3/4960/1 "2022-02-03T16:30:03Z")

</div>

`find_package(Python3 COMPONENTS Interpreter REQUIRED)` can find python3.

However, when I used `find_package(Python COMPONENTS Interpreter REQUIRED)`, it defaults to use python2 instead of python3 like the documentation indicates it should prefer.

Any ideas?

---

<div class="post-metadata">

### Author: ![developer](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/d/bcef8e/32.png) [@developer](https://discourse.cmake.org/u/developer)
#### Post date: [February 3, 2022, 5:57pm UTC](https://discourse.cmake.org/t/cmake-findpackage-python-is-not-preferring-python3/4960/2 "2022-02-03T17:57:42Z")

</div>

I’m thinking I found my issue. Elsewhere in my project I had `set(Python_EXECUTABLE "/usr/bin/python2.7")`. Would this explain why a subsequent find\_package(Python) was pointing to python 2 when both where installed?

I believe this was my issue.

---

<div class="post-metadata">

### Author: ![jtxa](https://discourse.cmake.org/user_avatar/discourse.cmake.org/jtxa/32/1535_2.png) [@jtxa](https://discourse.cmake.org/u/jtxa)
#### Post date: [February 3, 2022, 7:35pm UTC](https://discourse.cmake.org/t/cmake-findpackage-python-is-not-preferring-python3/4960/3 "2022-02-03T19:35:59Z")

</div>

If you explicitly set the path to the executable, the find module does not need to search for it anymore.  
Python3 works, because it uses `Python3_` as prefix for all variables.
