Home  >  Article  >  Backend Development  >  Install python from source code to any path under Linux (non-site-packages)

Install python from source code to any path under Linux (non-site-packages)

高洛峰
高洛峰Original
2017-03-28 16:51:452252browse

Take centos7 as an example:

To install python from the source code, generally install some devel packages first:

yum -y install xz wget gcc make gdbm-devel openssl-devel sqlite-devel zlib -devel bzip2-devel

Then download the source code

Unzip the source code:

tar -Jxf Python.x.tar.xz

cd Pyhton .x

./configure

There are some options here, --bindir: the path where python is located after the installation is complete

--prefix refers to the installation of python The prefix of the path, for example: If not specified, it will be /usr/local

After completion, the Makefile file will be generated. If you directly ./configure, python will be installed in

/usr/ Under local/lib/python27

But what if I want to install it in any path?

Makefile has the following line, just modify this

LIBDEST= $ (SCRIPTDIR)/python$(VERSION)

Do not overwrite the installation of python that comes with the operating system at any time, because some infrastructure uses python, such as: yum

The above is the detailed content of Install python from source code to any path under Linux (non-site-packages). For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn