# How to find a specific Python module?

**URL:** <https://discourse.cmake.org/t/how-to-find-a-specific-python-module/1393>\
**Category:** Code\
**Created:** [June 14, 2020, 10:07pm UTC](https://discourse.cmake.org/t/how-to-find-a-specific-python-module/1393 "2020-06-14T22:07:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![airwin](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/f4b2a3/32.png) [@airwin](https://discourse.cmake.org/u/airwin)\
**Post date:** [June 14, 2020, 10:07pm UTC](https://discourse.cmake.org/t/how-to-find-a-specific-python-module/1393/1 "2020-06-14T22:07:21Z")

</div>

I have a specific Python module that currently happens to be located at

/home/software/plplot/installcmake/lib/python3.7/site-packages/\_plplotc.so

The specific prefix part of that fullpath can be specified using the environment variable

CMAKE\_PREFIX\_PATH=/home/software/plplot/installcmake

But with that environment variable set,

find\_library(PLPLOT\_PYTHON\_MODULE\_LOCATION \_plplotc)

does not find that module, and I assume that is because of the other  
part of that python location, python3.7/site-packages varies from  
platform to platform (i.e., is not standardized enough for CMake to  
deal automatically with all the potential variations in that location for a given install  
prefix).

I need some discussion of this python module find issue.  
My guess at the moment is the best way to deal with this find issue  
is to update the CONFIG mode of the PLplot package to include this  
Python module location. If so and given that almost the entirety of  
that current configuration is generated automatically, is there a  
recommended way to update that configuration by hand to include the  
python module location for PLplot? And if there is a better way  
to deal with this find issue, please let me know what that is.

Alan

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [June 15, 2020, 12:40am UTC](https://discourse.cmake.org/t/how-to-find-a-specific-python-module/1393/2 "2020-06-15T00:40:23Z")

</div>

Why do you need the _path_ to that specific module?

What VTK does here is provide the path to add to `PYTHONPATH` to use for its Python code in its config file. [https://gitlab.kitware.com/vtk/vtk/blob/master/CMake/vtk-config.cmake.in#L157](https://gitlab.kitware.com/vtk/vtk/blob/master/CMake/vtk-config.cmake.in#L157) Hmm. It’s not exactly turn-key, but `VTK_PREFIX_PATH` can be used to reconstruct it the full path (its value is what it is to facilitate `install(DESTINATION)` usage with it).

---

<div class="post-metadata">

**Author:** ![airwin](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/f4b2a3/32.png) [@airwin](https://discourse.cmake.org/u/airwin)\
**Post date:** [June 15, 2020, 1:31am UTC](https://discourse.cmake.org/t/how-to-find-a-specific-python-module/1393/3 "2020-06-15T01:31:43Z")

</div>

> Why do you need the _path_ to that specific module?

It was a test of whether find\_library would work. But I just need the  
directory location of that module so I was planning to adjust  
PLPLOT\_PYTHON\_MODULE\_LOCATION afterword if that find worked, but  
it did not.

> What VTK does here is provide the path to add to `PYTHONPATH` to use for its Python code in its config file.  
> […] [https://gitlab.kitware.com/vtk/vtk/blob/master/CMake/vtk-config.cmake.in#L157](https://gitlab.kitware.com/vtk/vtk/blob/master/CMake/vtk-config.cmake.in#L157)

That approach (configuring the PLplot equivalent of  
VTK\_PYTHON\_SITE\_PACKAGES\_SUFFIX in the overall PLplot find\_package  
config file) should work well for my needs. So thanks for this idea  
which in retrospect is obvious, but my current plplotConfig.cmake file  
is quite simple and not configured so I was drawing a blank on this  
possiblity until your key help.
