Search code examples
pythonlinuxcentos

centOS 7 - difficulties with installing Python 3


I have a brand new centOS 7 VM that am trying to install Python 3 (currently 3.6.0) on. I am following a guide from Daniel Eriksson (https://danieleriksson.net/2017/02/08/how-to-install-latest-python-on-centos/)

but I'm running into an Pemission denied error when running the make && make altinstall command.

The last section of the error I'm getting is here:

gcc -pthread -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes    -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers   -I. -I./Include   -fPIC -DPy_BUILD_CORE -o Programs/_testembed.o ./Programs/_testembed.c
gcc -pthread -Wl,-rpath /usr/local/lib  -Xlinker -export-dynamic -o Programs/_testembed Programs/_testembed.o -L. -lpython3.6m -lpthread -ldl  -lutil   -lm  
# Substitution happens here, as the completely-expanded BINDIR
# is not available in configure
sed -e "s,@EXENAME@,/usr/local/bin/python3.6m," < ./Misc/python-config.in >python-config.py
# Replace makefile compat. variable references with shell script compat. ones;  -> 
LC_ALL=C sed -e 's,\$(\([A-Za-z0-9_]*\)),\$\{\1\},g' < Misc/python-config.sh >python-config
# On Darwin, always use the python version of the script, the shell
# version doesn't use the compiler customizations that are provided
# in python (_osx_support.py).
if test `uname -s` = Darwin; then \
    cp python-config.py python-config; \
fi
if test "no-framework" = "no-framework" ; then \
    /bin/install -c python /usr/local/bin/python3.6m; \
else \
    /bin/install -c -s Mac/pythonw /usr/local/bin/python3.6m; \
fi
/bin/install: cannot create regular file ‘/usr/local/bin/python3.6m’: Permission denied
make: *** [altbininstall] Error 1

I don't usually work with Linux, so I'm not exactly sure where to look for or what to try next. Any help on this appreciated. Thank you


Solution

  • The issue is with the permission required when running the command to install the package.

    Use
    sudo make && sudo make altinstall

    instead of:
    sudo make && make altinstall