pyenv / pyenv

Simple Python version management
MIT License
38.7k stars 3.02k forks source link

Unable to install a python version using pyenv on Fedora 27 with message 'configure:4018: error: C compiler cannot create executables' #1076

Closed GabLeRoux closed 6 years ago

GabLeRoux commented 6 years ago

install command

CFLAGS=-I/usr/include/openssl \
LDFLAGS=-L/usr/lib64 \
pyenv install -v 3.4.2

output

/tmp/python-build.20180115180746.18522 ~/python-fix/Python-3.4.2
Downloading Python-3.4.2.tar.xz...
-> https://www.python.org/ftp/python/3.4.2/Python-3.4.2.tar.xz
/tmp/python-build.20180115180746.18522/Python-3.4.2 /tmp/python-build.20180115180746.18522 ~/python-fix/Python-3.4.2
Installing Python-3.4.2...
patching file ./Lib/ssl.py
patching file ./Modules/_ssl.c
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... linux
checking for --without-gcc... no
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/tmp/python-build.20180115180746.18522/Python-3.4.2':
configure: error: C compiler cannot create executables
See `config.log' for more details

BUILD FAILED (Fedora 27 using python-build 20160602)

Inspect or clean up the working tree at /tmp/python-build.20180115180746.18522
Results logged to /tmp/python-build.20180115180746.18522.log

Last 10 log lines:
checking host system type... x86_64-unknown-linux-gnu
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... linux
checking for --without-gcc... no
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/tmp/python-build.20180115180746.18522/Python-3.4.2':
configure: error: C compiler cannot create executables
See `config.log' for more details

Log file

➜  ~ cat /tmp/python-build.20180115121407.13048/Python-3.4.2/config.log
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by python configure 3.4, which was
generated by GNU Autoconf 2.69.  Invocation command line was

  $ ./configure --prefix=/home/laprise/.pyenv/versions/3.4.2 --libdir=/home/laprise/.pyenv/versions/3.4.2/lib

## --------- ##
## Platform. ##
## --------- ##

hostname = hpbenlocalhost
uname -m = x86_64
uname -r = 4.14.11-300.fc27.x86_64
uname -s = Linux
uname -v = #1 SMP Wed Jan 3 13:52:28 UTC 2018

/usr/bin/uname -p = x86_64
/bin/uname -X     = unknown

/bin/arch              = x86_64
/usr/bin/arch -k       = unknown
/usr/convex/getsysinfo = unknown
/usr/bin/hostinfo      = unknown
/bin/machine           = unknown
/usr/bin/oslevel       = unknown
/bin/universe          = unknown

PATH: /home/laprise/.pyenv/libexec
PATH: /home/laprise/.pyenv/plugins/python-build/bin
PATH: /home/laprise/.pyenv/plugins/pyenv-virtualenv/bin
PATH: /home/laprise/.pyenv/plugins/pyenv-update/bin
PATH: /home/laprise/.pyenv/plugins/pyenv-installer/bin
PATH: /home/laprise/.pyenv/plugins/pyenv-doctor/bin
PATH: /home/laprise/.pyenv/plugins/pyenv-virtualenv/shims
PATH: /home/laprise/.pyenv/shims
PATH: /home/laprise/.pyenv/bin
PATH: /home/laprise/local/bin
PATH: /usr/local/bin
PATH: /usr/local/sbin
PATH: /usr/bin
PATH: /usr/sbin
PATH: /home/laprise/bin

## ----------- ##
## Core tests. ##
## ----------- ##

configure:2883: checking build system type
configure:2897: result: x86_64-unknown-linux-gnu
configure:2917: checking host system type
configure:2930: result: x86_64-unknown-linux-gnu
configure:3042: checking for --enable-universalsdk
configure:3089: result: no
configure:3112: checking for --with-universal-archs
configure:3127: result: no
configure:3277: checking MACHDEP
configure:3483: result: linux
configure:3504: checking for --without-gcc
configure:3527: result: no
configure:3651: checking for gcc
configure:3667: found /usr/bin/gcc
configure:3678: result: gcc
configure:3907: checking for C compiler version
configure:3916: gcc --version >&5
gcc (GCC) 7.2.1 20170915 (Red Hat 7.2.1-2)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

configure:3927: $? = 0
configure:3916: gcc -v >&5
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/7/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,objc,obj-c++,fortran,ada,go,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl --enable-libmpx --enable-offload-targets=nvptx-none --without-cuda-driver --enable-gnu-indirect-function --with-tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux
Thread model: posix
gcc version 7.2.1 20170915 (Red Hat 7.2.1-2) (GCC)
configure:3927: $? = 0
configure:3916: gcc -V >&5
gcc: error: unrecognized command line option '-V'
gcc: fatal error: no input files
compilation terminated.
configure:3927: $? = 1
configure:3916: gcc -qversion >&5
gcc: error: unrecognized command line option '-qversion'; did you mean '--version'?
gcc: fatal error: no input files
compilation terminated.
configure:3927: $? = 1
configure:3947: checking whether the C compiler works
configure:3969: gcc  -I/home/laprise/.pyenv/versions/3.4.2/include  -L/home/laprise/.pyenv/versions/3.4.2/lib  conftest.c  >&5
/usr/bin/ld: skipping incompatible /usr/lib/gcc/x86_64-redhat-linux/7/../../../libc.so when searching for -lc
/usr/bin/ld: skipping incompatible //lib/libc.so when searching for -lc
/usr/bin/ld: skipping incompatible //usr/lib/libc.so when searching for -lc
/usr/bin/ld: cannot find -lc
collect2: error: ld returned 1 exit status
configure:3973: $? = 1
configure:4011: result: no
configure: failed program was:
| /* confdefs.h */
| #define _GNU_SOURCE 1
| #define _NETBSD_SOURCE 1
| #define __BSD_VISIBLE 1
| #define _BSD_TYPES 1
| #define _DARWIN_C_SOURCE 1
| #define _XOPEN_SOURCE 700
| #define _XOPEN_SOURCE_EXTENDED 1
| #define _POSIX_C_SOURCE 200809L
| /* end confdefs.h.  */
|
| int
| main ()
| {
|
|   ;
|   return 0;
| }
configure:4016: error: in `/tmp/python-build.20180115121407.13048/Python-3.4.2':
configure:4018: error: C compiler cannot create executables
See `config.log' for more details

## ---------------- ##
## Cache variables. ##
## ---------------- ##

ac_cv_build=x86_64-unknown-linux-gnu
ac_cv_env_CC_set=
ac_cv_env_CC_value=
ac_cv_env_CFLAGS_set=
ac_cv_env_CFLAGS_value=
ac_cv_env_CPPFLAGS_set=set
ac_cv_env_CPPFLAGS_value='-I/home/laprise/.pyenv/versions/3.4.2/include '
ac_cv_env_CPP_set=
ac_cv_env_CPP_value=
ac_cv_env_LDFLAGS_set=set
ac_cv_env_LDFLAGS_value='-L/home/laprise/.pyenv/versions/3.4.2/lib '
ac_cv_env_LIBS_set=
ac_cv_env_LIBS_value=
ac_cv_env_MACHDEP_set=
ac_cv_env_MACHDEP_value=
ac_cv_env_build_alias_set=
ac_cv_env_build_alias_value=
ac_cv_env_host_alias_set=
ac_cv_env_host_alias_value=
ac_cv_env_target_alias_set=
ac_cv_env_target_alias_value=
ac_cv_host=x86_64-unknown-linux-gnu
ac_cv_prog_ac_ct_CC=gcc

## ----------------- ##
## Output variables. ##
## ----------------- ##

ABIFLAGS=''
AR=''
ARCH_RUN_32BIT=''
ARFLAGS=''
ASDLGEN=''
BASECFLAGS=''
BASECPPFLAGS=''
BLDLIBRARY=''
BLDSHARED=''
BUILDEXEEXT=''
CC='gcc'
CCSHARED=''
CFLAGS=''
CFLAGSFORSHARED=''
CFLAGS_NODIST=''
CONFIGURE_MACOSX_DEPLOYMENT_TARGET=''
CONFIG_ARGS=' '\''--prefix=/home/laprise/.pyenv/versions/3.4.2'\'' '\''--libdir=/home/laprise/.pyenv/versions/3.4.2/lib'\'' '\''LDFLAGS=-L/home/laprise/.pyenv/versions/3.4.2/lib '\'' '\''CPPFLAGS=-I/home/laprise/.pyenv/versions/3.4.2/include '\'''
CPP=''
CPPFLAGS='-I/home/laprise/.pyenv/versions/3.4.2/include '
CXX=''
DEFS=''
DLINCLDIR=''
DLLLIBRARY=''
DYNLOADFILE=''
ECHO_C=''
ECHO_N='-n'
ECHO_T=''
EGREP=''
ENSUREPIP=''
EXEEXT=''
EXPORT_MACOSX_DEPLOYMENT_TARGET='#'
EXT_SUFFIX=''
FRAMEWORKALTINSTALLFIRST=''
FRAMEWORKALTINSTALLLAST=''
FRAMEWORKINSTALLAPPSPREFIX=''
FRAMEWORKINSTALLFIRST=''
FRAMEWORKINSTALLLAST=''
FRAMEWORKPYTHONW=''
FRAMEWORKUNIXTOOLSPREFIX='/home/laprise/.pyenv/versions/3.4.2'
GNULD=''
GREP=''
HAS_HG='no-repository'
HAVE_GETHOSTBYNAME=''
HAVE_GETHOSTBYNAME_R=''
HAVE_GETHOSTBYNAME_R_3_ARG=''
HAVE_GETHOSTBYNAME_R_5_ARG=''
HAVE_GETHOSTBYNAME_R_6_ARG=''
HGBRANCH=''
HGTAG=''
HGVERSION=''
INSTALL_DATA=''
INSTALL_PROGRAM=''
INSTALL_SCRIPT=''
INSTSONAME=''
LDCXXSHARED=''
LDFLAGS='-L/home/laprise/.pyenv/versions/3.4.2/lib '
LDLAST=''
LDLIBRARY=''
LDLIBRARYDIR=''
LDSHARED=''
LDVERSION=''
LIBC=''
LIBFFI_INCLUDEDIR=''
LIBM=''
LIBOBJS=''
LIBPL=''
LIBRARY=''
LIBS=''
LIBTOOL_CRUFT=''
LINKCC=''
LINKFORSHARED=''
LIPO_32BIT_FLAGS=''
LN=''
LTLIBOBJS=''
MACHDEP='linux'
MACHDEP_OBJS=''
MAINCC=''
MKDIR_P=''
MULTIARCH=''
NO_AS_NEEDED=''
OBJEXT=''
OPT=''
OTHER_LIBTOOL_OPT=''
PACKAGE_BUGREPORT='http://bugs.python.org/'
PACKAGE_NAME='python'
PACKAGE_STRING='python 3.4'
PACKAGE_TARNAME='python'
PACKAGE_URL=''
PACKAGE_VERSION='3.4'
PATH_SEPARATOR=':'
PKG_CONFIG=''
PY3LIBRARY=''
PYTHON=''
PYTHONFRAMEWORK=''
PYTHONFRAMEWORKDIR='no-framework'
PYTHONFRAMEWORKIDENTIFIER='org.python.python'
PYTHONFRAMEWORKINSTALLDIR=''
PYTHONFRAMEWORKPREFIX=''
PYTHON_FOR_BUILD='./$(BUILDPYTHON) -E'
PY_ENABLE_SHARED=''
RANLIB=''
READELF=''
RUNSHARED=''
SGI_ABI=''
SHELL='/bin/sh'
SHLIBS=''
SHLIB_SUFFIX=''
SIGNAL_OBJS=''
SOABI=''
SOVERSION='1.0'
SRCDIRS=''
TCLTK_INCLUDES=''
TCLTK_LIBS=''
THREADHEADERS=''
THREADOBJ=''
TRUE=''
UNIVERSALSDK=''
UNIVERSAL_ARCH_FLAGS=''
USE_INLINE=''
USE_SIGNAL_MODULE=''
USE_THREAD_MODULE=''
VERSION='3.4'
_PYTHON_HOST_PLATFORM=''
ac_ct_AR=''
ac_ct_CC='gcc'
ac_ct_CXX=''
ac_ct_READELF=''
bindir='${exec_prefix}/bin'
build='x86_64-unknown-linux-gnu'
build_alias=''
build_cpu='x86_64'
build_os='linux-gnu'
build_vendor='unknown'
datadir='${datarootdir}'
datarootdir='${prefix}/share'
docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
dvidir='${docdir}'
exec_prefix='NONE'
host='x86_64-unknown-linux-gnu'
host_alias=''
host_cpu='x86_64'
host_os='linux-gnu'
host_vendor='unknown'
htmldir='${docdir}'
includedir='${prefix}/include'
infodir='${datarootdir}/info'
libdir='/home/laprise/.pyenv/versions/3.4.2/lib'
libexecdir='${exec_prefix}/libexec'
localedir='${datarootdir}/locale'
localstatedir='${prefix}/var'
mandir='${datarootdir}/man'
oldincludedir='/usr/include'
pdfdir='${docdir}'
prefix='/home/laprise/.pyenv/versions/3.4.2'
program_transform_name='s,x,x,'
psdir='${docdir}'
sbindir='${exec_prefix}/sbin'
sharedstatedir='${prefix}/com'
sysconfdir='${prefix}/etc'
target_alias=''

## ----------- ##
## confdefs.h. ##
## ----------- ##

/* confdefs.h */
#define _GNU_SOURCE 1
#define _NETBSD_SOURCE 1
#define __BSD_VISIBLE 1
#define _BSD_TYPES 1
#define _DARWIN_C_SOURCE 1
#define _XOPEN_SOURCE 700
#define _XOPEN_SOURCE_EXTENDED 1
#define _POSIX_C_SOURCE 200809L

configure: exit 77

I installed using pyenv/pyenv-installer and added the env flags to my ~/.zshrc as mentioned after installation and restarted the shell.

I also installed all the required packages as mentioned in wiki's home suggested-build-environment:

dnf install -y gcc zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel tk-devel

And the packages mentioned in Common-build-problems#requirements

dnf install zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel xz xz-devel

Note that it differs one from an other, I think this is also an issue, packages should be the same for both sections.

I also installed the following packages: clang and build-essentials equivalent: dnf install @development-tools. I am not sure what is missing.

GabLeRoux commented 6 years ago

I tried again manually and it looks like the problem is not with pyenv but with building python itself. I tried with a few versions, 2.7, 3.6.3, 3.4.2, etc. Always the same output.

I also tried to build python manually:

wget https://www.python.org/ftp/python/3.4.2/Python-3.4.2.tar.xz
tar xf Python-3.4.2.tar.xz
cd Python-3.4
./configure
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... linux
checking for --without-gcc... no
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/home/laprise/python-fix/Python-3.4.2':
configure: error: C compiler cannot create executables
See `config.log' for more details
yyuu commented 6 years ago

Don’t ask us about compiler issue of yours. It’s clear your C compiler has issue.

GabLeRoux commented 6 years ago

@yyuu I understand, all I did was to follow the steps described in pyenv documentation on a fresh fedora install, and it didn't work out of the box so I thought it'd be worth mentioning here.

I'll keep digging and post answer here anyway for further reference. It would be nice if you could also point me where this question should go.

GabLeRoux commented 6 years ago

After further investigation, the problem is indeed with the C compiler as one would expect from original error message.

So I tried to compile a simple c file:

helloworld.c

#include<stdio.h>
main() {
    printf("Hello World");
}
gcc helloworld.c
In file included from /usr/include/features.h:447:0,
                 from /usr/include/bits/libc-header-start.h:33,
                 from /usr/include/stdio.h:27,
                 from helloword.c:1:
/usr/include/gnu/stubs.h:10:11: fatal error: gnu/stubs-64.h: No such file or directory
 # include <gnu/stubs-64.h>
           ^~~~~~~~~~~~~~~~
compilation terminated.

Let's confirm the file is not there

ls /usr/include/gnu/
libc-version.h  lib-names-32.h  lib-names.h  stubs-32.h  stubs.h

One way to figure out what package provides a specific file is to run dnf provides:

sudo dnf provides /usr/include/gnu/stubs-64.h
Last metadata expiration check: 0:36:06 ago on Mon 15 Jan 2018 06:55:28 PM EST.
glibc-devel-2.26-21.fc27.x86_64 : Object files for development using standard C
                                : libraries.
Repo        : updates
Matched from:
Filename    : /usr/include/gnu/stubs-64.h

glibc-devel-2.26-15.fc27.x86_64 : Object files for development using standard C
                                : libraries.
Repo        : fedora
Matched from:
Filename    : /usr/include/gnu/stubs-64.h

I do have that package installed, maybe reinstalling it could fix somehting:

sudo dnf reinstall -y glibc-devel

but /usr/include/gnu/stubs-64.h is still not present.

sudo dnf list | grep glibc-devel
glibc-devel.i686                       2.26-21.fc27                    @updates 
glibc-devel.x86_64                     2.26-21.fc27                    updates 

According to provides command, my current version should provide that file, but I ran ls /usr/include/gnu/stubs-64.h and it's still missing.

The system is a 64bit system:

uname -a
Linux hpbenlocalhost 4.14.11-300.fc27.x86_64 #1 SMP Wed Jan 3 13:52:28 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Continuing investigation.

GabLeRoux commented 6 years ago

I managed to get passed the above C compiler error about missing stubs-64.h with the following command:

sudo dnf reinstall -y glibc-devel.x86_64

Hard to tell why sudo dnf list | grep glibc-devel showed both i686 and x86_64. The reinstall command for glibc-devel didn't do anything but specifying glibc-devel.x86_64 directly did the trick 👍


Now that /usr/include/gnu/stubs-64.h can be found, I'm getting a different error:

CFLAGS=-I/usr/include/openssl \
LDFLAGS=-L/usr/lib64 \
pyenv install -v 3.4.2
Downloading Python-3.4.2.tar.xz...
-> https://www.python.org/ftp/python/3.4.2/Python-3.4.2.tar.xz
Installing Python-3.4.2...
patching file ./Lib/ssl.py
patching file ./Modules/_ssl.c
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems

BUILD FAILED (Fedora 27 using python-build 20160602)

Inspect or clean up the working tree at /tmp/python-build.20180115195610.6612
Results logged to /tmp/python-build.20180115195610.6612.log

Last 10 log lines:
(cd /home/laprise/.pyenv/versions/3.4.2/share/man/man1; ln -s python3.4.1 python3.1)
if test "xupgrade" != "xno"  ; then \
    case upgrade in \
        upgrade) ensurepip="--upgrade" ;; \
        install|*) ensurepip="" ;; \
    esac; \
     ./python -E -m ensurepip \
        $ensurepip --root=/ ; \
fi
Ignoring ensurepip failure: pip 1.5.6 requires SSL/TLS

Which is documented in the Common build problems 'ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?'

sudo dnf list | grep openssl
openssl.x86_64                         1:1.1.0g-1.fc27                 @updates 
[...]
openssl-devel.x86_64                   1:1.1.0g-1.fc27                 @updates 
openssl-devel.i686                     1:1.1.0g-1.fc27                 updates

So I tried to reinstall all the required packages (the ones mentioned in the wiki)

dnf reinstall -y zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel xz xz-devel

That didn't help this time. I also tried to reinstall openssl-devel.x86_64, but I'm still getting the same error.

GabLeRoux commented 6 years ago

Alright, so I managed to get passed the openssl issue now, looks like it's related to https://github.com/pyenv/pyenv/issues/916

I successfully installed python 3.6.3 even tho python 3.4.2 is still failing.

openssl version
OpenSSL 1.1.0g-fips  2 Nov 2017
Ehco1996 commented 3 years ago

maybe you xcode settings is wrong

try this:

Start Xcode, select 'Preferences', then 'Locations'. 
You'll notice a dropdown control at 'Command Line Tools'.
Select the newest version, close the dialog window, 
then call brew again. Restart your computer and run it again.