# How to limit find\_package(Python3 \<version\> ...) to select from a directory of multiple python subdirectories

**URL:** https://discourse.cmake.org/t/how-to-limit-find-package-python3-version-to-select-from-a-directory-of-multiple-python-subdirectories/3441
**Category:** Usage
**Created:** [May 30, 2021, 4:28pm UTC](https://discourse.cmake.org/t/how-to-limit-find-package-python3-version-to-select-from-a-directory-of-multiple-python-subdirectories/3441 "2021-05-30T16:28:53Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![JFlinn](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/j/d07c76/32.png) [@JFlinn](https://discourse.cmake.org/u/JFlinn)
#### Post date: [May 30, 2021, 4:28pm UTC](https://discourse.cmake.org/t/how-to-limit-find-package-python3-version-to-select-from-a-directory-of-multiple-python-subdirectories/3441/1 "2021-05-30T16:28:53Z")

</div>

I have a Directory:  
ffs-MacBook-Pro python % pwd  
/ourbuilds/python  
ffs-MacBook-Pro python % ls  
python-2.7 python-3.6.1 python-3.8 python27 python37  
python-3.5 python-3.7 python-3.8.0 python-3.8.2 python35 python38  
python-3.6 python-3.7.0 python-3.7.3 python-3.8.3 python36 src  
ffs-MacBook-Pro python %

What is the recommended way of using find\_package to select python 3.7.3. Note that this list of python versions gets updated reasonably often by IT. Also must work similarly across windows/mac/linux.

---

<div class="post-metadata">

### Author: ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)
#### Post date: [May 30, 2021, 9:29pm UTC](https://discourse.cmake.org/t/how-to-limit-find-package-python3-version-to-select-from-a-directory-of-multiple-python-subdirectories/3441/2 "2021-05-30T21:29:19Z")

</div>

It depends on what you want to search for.

If you want `3.7.3`, use `find_package(Python3 3.7.3 EXACT)`.

If you want version `3.7`, regardless of the third digit, you can specify `find_package(Python3 3.7 EXACT)`. In this case, the version `3.7.x`, with the greatest value for `x`, will be founded.

And if you want to search specifically in a directory, set variable `Python3_ROOT`:

```cmake
set(Python3_ROOT /ourbuilds/python)
find_package(Python3 3.7 EXACT)

```
