Django and xadmin build backstage management system-django development environment

Posted by fabrice on Fri, 19 Jul 2019 12:32:48 +0200

Learning environment: redhat 5.8
python version: 3.6.8
django version: 1.11.20

1.python environment installation

First, open the following official web site to download the source installation package directly:
https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tar.xz
After downloading, upload it to the linux environment and extract it from the command line:

xz -d Python-3.6.8.tar.xz
tar xvf Python-3.6.8.tar

Then install:

./configure
make

But compilation has always been wrong: the _ssl and _hashlib modules failed to compile, after verification, guess that my redhat version is too low, and then the version of OpenSSL is relatively low, need to upgrade openssl.

First, uninstall the old openssl package using the following commands:

rpm -qa|grep openssl
rpm -e XXXX

Note: Don't upgrade openssl easily, because there are many system services that depend on this package. It's best to do it on a separate development machine, otherwise it may affect your other business.

We download the openssl-1.0.2h.tar.gz package from the OpenSSL official website. After decompression, we use the following commands:

./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl -Wl,-rpath,/usr/local/ssl/lib shared

shared is a dynamic library specified for compilation, otherwise it will be compiled into a static library libssl.a file by default.
Then execute the following commands:

make 
make install

After loading, continue compiling python, or report the following error:

WARNING: renaming "_ssl" since importing it failed: libssl.so.1.0.0: cannot open shared object file: No such file or directory

WARNING: renaming "_hashlib" since importing it failed: libssl.so.1.0.0: cannot open shared object file: No such file or directory

Note that no dynamic libraries were found. We found the directory of libssl.so, as follows:

find / -name libssl.so*

Installed in the / usr/local/ssl/lib directory, execute the following commands:

echo "/usr/local/ssl/lib" >> /etc/ld.so.conf
ldconfig -v

Re-compiled, ssl and hashlib modules compiled successfully.

Install after compiling, the commands are as follows:

make install

Look at python at this point, or the old version 3.5, because there is no link created, according to the complete process, we recompile as follows:

mkdir /usr/local/python3.6.8
./configure --prefix=/usr/local/python3.6.8
make 
make install
rm -f /usr/bin/python
ln -s /usr/local/python3.6.8/bin/python3 /usr/bin/python

Enter Python into the python command line, as follows:

Python 3.6.8 (default, May 14 2019, 09:54:58) 
[GCC 7.1.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

You can see that python is already version 3.6.8.

Pip is a very important command in python, so pip is also re-linked to the new version. Note that PIP does not need to be installed any more. In Python version 3.6.8, a new PIP package has been included:

rm -f /usr/bin/pip
ln -s /usr/local/python3.6.8/bin/pip3 /usr/bin/pip

Installation of 2.django

Next, install django and download Django-1.11.20.tar.gz on the official django website.
After decompression, execute the command:

python setup.py install

Error reporting, no pytz module.
Use pip to install pytz module:

pip install pytz

The installation was successful.

Reexecute commands in the django directory:

python setup.py install

The following words appear to indicate that the installation was successful:

Using /usr/local/python3.6.8/lib/python3.6/site-packages
Finished processing dependencies for Django==1.11.20

We install using root users, but it is dangerous to use root users. We create a dedicated user for python development and execute the following commands:

useradd pycode
passwd pycode  #Create a password, where the password is the same as the username: pycode.

su - pycode enters the pycode user's root directory / home/pycode directory, where a complete development environment for django is built.


Topics: Python Django pip OpenSSL