Skip to content

Instantly share code, notes, and snippets.

@Waltibaba
Last active February 7, 2017 13:46
Show Gist options
  • Select an option

  • Save Waltibaba/f638d5aabeecffe2471b0ca647ce8adf to your computer and use it in GitHub Desktop.

Select an option

Save Waltibaba/f638d5aabeecffe2471b0ca647ce8adf to your computer and use it in GitHub Desktop.

Revisions

  1. Waltibaba revised this gist Feb 7, 2017. 1 changed file with 13 additions and 8 deletions.
    21 changes: 13 additions & 8 deletions wrong python version args - with cmake
    Original file line number Diff line number Diff line change
    @@ -1,16 +1,21 @@
    http://stackoverflow.com/questions/15291500/i-have-2-versions-of-python-installed-but-cmake-is-using-older-version-how-do
    I had a similar problem, and resolved it using @Paul's answer as a hint. I needed to use python2.7 to compile an older library, but cmake keeps picking up my python3.2 libraries (and executable).

    First, I ran cmake with default options, then edited the CMakeCache.txt file which it generated. I did it this way primarily because I didn't know the proper -D... incantations to cause cmake to get the python library and include paths, etc right in the first place.
    EITHER:
    find_package( PythonLibs 2.7 REQUIRED ) # if it already has a find_package(PythonLibs)

    OR:
    needed to use python2.7 to compile an older library, but cmake keeps picking up my python3.2 libraries (and executable).
    First, I ran cmake with default options, then edited the CMakeCache.txt file which it generated. I did it this way primarily because I didn't know the proper -D... incantations to cause cmake to get the python library and include paths, etc right in the first place.
    In my CmakeCache.txt, I found lines like this

    Path to a program
    PYTHON_EXECUTABLE:FILEPATH=/usr/bin/python
    Path to a directory
    PYTHON_INCLUDE_DIR:PATH=/usr/include/python3.2
    Path to a library
    PYTHON_LIBRARY:FILEPATH=/usr/lib/libpython3.2.so
    PYTHON_EXECUTABLE:FILEPATH=/usr/bin/python
    PYTHON_INCLUDE_DIR:PATH=/usr/include/python3.2
    PYTHON_LIBRARY:FILEPATH=/usr/lib/libpython3.2.so

    And replaced every occurrence of python3.2 with python2.7. I also had to rename the PYTHON_EXECUTABLE to use python2.7, since python is a symlink to python3.2 on my system.

    PYTHON_EXECUTABLE:FILEPATH=/usr/bin/python2
    PYTHON_INCLUDE_DIR:PATH=/usr/include/python2.7
    PYTHON_LIBRARY:FILEPATH=/usr/lib64/libpython2.7.so

    Then I reran cmake. Because it prefers its cached values to actually looking for the libraries, this should work in all cases. At least, it did in mine.
  2. Waltibaba revised this gist Feb 7, 2017. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions wrong python version args - with cmake
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,4 @@
    http://stackoverflow.com/questions/15291500/i-have-2-versions-of-python-installed-but-cmake-is-using-older-version-how-do
    I had a similar problem, and resolved it using @Paul's answer as a hint. I needed to use python2.7 to compile an older library, but cmake keeps picking up my python3.2 libraries (and executable).

    First, I ran cmake with default options, then edited the CMakeCache.txt file which it generated. I did it this way primarily because I didn't know the proper -D... incantations to cause cmake to get the python library and include paths, etc right in the first place.
  3. Waltibaba created this gist Feb 7, 2017.
    15 changes: 15 additions & 0 deletions wrong python version args - with cmake
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    I had a similar problem, and resolved it using @Paul's answer as a hint. I needed to use python2.7 to compile an older library, but cmake keeps picking up my python3.2 libraries (and executable).

    First, I ran cmake with default options, then edited the CMakeCache.txt file which it generated. I did it this way primarily because I didn't know the proper -D... incantations to cause cmake to get the python library and include paths, etc right in the first place.

    In my CmakeCache.txt, I found lines like this

    Path to a program
    PYTHON_EXECUTABLE:FILEPATH=/usr/bin/python
    Path to a directory
    PYTHON_INCLUDE_DIR:PATH=/usr/include/python3.2
    Path to a library
    PYTHON_LIBRARY:FILEPATH=/usr/lib/libpython3.2.so
    And replaced every occurrence of python3.2 with python2.7. I also had to rename the PYTHON_EXECUTABLE to use python2.7, since python is a symlink to python3.2 on my system.

    Then I reran cmake. Because it prefers its cached values to actually looking for the libraries, this should work in all cases. At least, it did in mine.