diff --git a/.travis.yml b/.travis.yml
index f4bb32d70af8ebcde428dc7fc55672f230e3a25b..a35bbdd11f868c577c049c713258421b5276e820 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -75,7 +75,9 @@ script:
   - mkdir build
   - cd build
   - export CMAKE_PREFIX_PATH=/tmp/_ci/install
-  - cmake .. -DPYTHON_EXECUTABLE=$PYTHON_DEFAULT_VERSION -DPYTHON_INCLUDE_DIR=$($PYTHON_DEFAULT_VERSION -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") -DPYTHON_LIBRARY=$($PYTHON_DEFAULT_VERSION -c "import distutils.sysconfig as sysconfig; print(sysconfig.get_config_var('LIBDIR'))")
+  - export PYTHON_DEFAULT_VERSION=$(which python2)
+  - if [[ $TRAVIS_PYTHON_VERSION -gt 30 ]]; then export PYTHON_DEFAULT_VERSION=$(which python3); fi
+  - cmake .. -DPYTHON_EXECUTABLE=$PYTHON_DEFAULT_VERSION 
   - make
   - ./extra_lib
   - cd /tmp/_ci/build
diff --git a/travis_custom/custom_before_install b/travis_custom/custom_before_install
index 678c5f66d423b1432102b3320a4ab80fc2f22887..9fbf67f3a6737793c537863274f5c8b3df5a6af5 100755
--- a/travis_custom/custom_before_install
+++ b/travis_custom/custom_before_install
@@ -2,10 +2,8 @@
 
 # Add Python dependency
 echo "TRAVIS_PYTHON_VERSION=$TRAVIS_PYTHON_VERSION"
-export PYTHON_DEFAULT_VERSION=$(which python2)
 if [[ $TRAVIS_PYTHON_VERSION -gt 30 ]]; then
   export APT_DEPENDENCIES=$APT_DEPENDENCIES" python3-numpy"
-  export PYTHON_DEFAULT_VERSION=$(which python3)
 fi
 
 # When this script is called the current directory is ./custom_travis